Github user holdenk commented on a diff in the pull request:
https://github.com/apache/spark/pull/8152#discussion_r37038064
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/feature/StringIndexerSuite.scala ---
@@ -120,4 +108,36 @@ class StringIndexerSuite extends SparkFunSuite with
MLlibTestSparkContext {
val df = sqlContext.range(0L, 10L)
assert(indexerModel.transform(df).eq(df))
}
+
+ test("IndexToString params") {
+ val idxToStr = new IndexToString()
+ ParamsSuite.checkParams(idxToStr)
+ }
+
+ test("IndexToString.transform") {
+ val labels = Array("a", "b", "c")
+ val df0 = sqlContext.createDataFrame(Seq(
+ (0, "a"), (1, "b"), (2, "c"), (0, "a")
+ )).toDF("index", "expected")
+
+ val idxToStr0 = new IndexToString()
+ .setInputCol("index")
+ .setOutputCol("actual")
+ .setLabels(labels)
+ idxToStr0.transform(df0).select("actual",
"expected").collect().foreach {
+ case Row(actual, expected) =>
+ assert(actual === expected)
+ }
+
+ val attr = NominalAttribute.defaultAttr.withValues(labels)
--- End diff --
This is a super minor point, but since the original intent was to provide
an inverse transform for the StringIndexer, maybe checking that this works with
the metadata set by the StringIndexer would be better than manually specifying
the attribute?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]