Github user BenFradet commented on a diff in the pull request:
https://github.com/apache/spark/pull/10355#discussion_r57219723
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/classification/RandomForestClassifierSuite.scala
---
@@ -178,6 +179,34 @@ class RandomForestClassifierSuite extends
SparkFunSuite with MLlibTestSparkConte
assert(importances.toArray.forall(_ >= 0.0))
}
+ test("should support all NumericType labels") {
+ val dfs = MLTestingUtils.genClassifDFWithNumericLabelCol(sqlContext,
"label", "features")
+
+ val rf = new RandomForestClassifier().setFeaturesCol("features")
+
+ val expected = rf.setLabelCol("label")
+ .fit(TreeTests.setMetadata(dfs(DoubleType), 2, "label"))
+ dfs.keys.filter(_ != DoubleType).foreach { t =>
+ TreeTests.checkEqual(expected,
+ rf.setLabelCol("label").fit(TreeTests.setMetadata(dfs(t), 2,
"label")))
+ }
+ }
+
+ test("shouldn't support non NumericType labels") {
--- End diff --
I wanted to be able to do something like:
```scala
def checkNumericTypes[T <: Regressor, M <: Model](
regressor: T, sqlContext: SQLContext)(asserts: Seq[(M, M) => Unit]):
Unit = {
val dfs = MLTestingUtils.genRegressionDFWithNumericLabelCol(sqlContext,
"label", "features")
val expected = regressor.fit(dfs(DoubleType))
dfs.keys.filter(_ != DoubleType).foreach { t =>
val actual = regressor.fit(dfs(t))
asserts.foreach(f => f(expected, actual))
}
}
```
But unfortunately that doesn't work since I'm not able to capture which
model is being created by the regressor's `fit` method.
---
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]