Github user yanboliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/9302#discussion_r43753637
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/feature/RFormulaSuite.scala ---
@@ -107,6 +107,25 @@ class RFormulaSuite extends SparkFunSuite with
MLlibTestSparkContext {
assert(result.collect() === expected.collect())
}
+ test("index string label") {
+ val formula = new RFormula().setFormula("id ~ a + b")
+ val original = sqlContext.createDataFrame(
+ Seq(("male", "foo", 4), ("female", "bar", 4), ("female", "bar", 5),
("male", "baz", 5))
+ ).toDF("id", "a", "b")
+ val model = formula.fit(original)
+ val result = model.transform(original)
+ val resultSchema = model.transformSchema(original.schema)
+ val expected = sqlContext.createDataFrame(
+ Seq(
+ ("male", "foo", 4, Vectors.dense(0.0, 1.0, 4.0), 1.0),
+ ("female", "bar", 4, Vectors.dense(1.0, 0.0, 4.0), 0.0),
+ ("female", "bar", 5, Vectors.dense(1.0, 0.0, 5.0), 0.0),
+ ("male", "baz", 5, Vectors.dense(0.0, 0.0, 5.0), 1.0))
+ ).toDF("id", "a", "b", "features", "label")
+ // assert(result.schema.toString == resultSchema.toString)
--- End diff --
Currently disable this assert due to ```StringIndexer``` output
inconsistent ```nullable```, I opened
[SPARK-11478](https://issues.apache.org/jira/browse/SPARK-11478) to track that
issue. After it resolved, this assert will be enabled.
---
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]