srowen commented on a change in pull request #17864: [SPARK-20604][ML] Allow
imputer to handle numeric types
URL: https://github.com/apache/spark/pull/17864#discussion_r309388602
##########
File path: mllib/src/test/scala/org/apache/spark/ml/feature/ImputerSuite.scala
##########
@@ -176,6 +178,51 @@ class ImputerSuite extends MLTest with
DefaultReadWriteTest {
assert(newInstance.surrogateDF.collect() ===
instance.surrogateDF.collect())
}
+ test("Imputer for Numeric with default missing Value NaN") {
+ val df = spark.createDataFrame(Seq(
+ (0, 1.0, 1.0, 1.0),
+ (1, 11.0, 11.0, 11.0),
+ (2, 3.6, 3.6, 3.6),
+ (3, Double.NaN, 5.2, 3.6)
+ )).toDF("id", "value1", "expected_mean_value1_double",
"expected_median_value1_double")
+
+ val imputer = new Imputer()
+ .setInputCols(Array("value1"))
+ .setOutputCols(Array("out1"))
+
+ val types = Seq(ShortType, IntegerType, LongType, FloatType, DoubleType,
Review comment:
I think this is fine, but wouldn't necessarily bother with anything but
Integer Long, maybe Float. (Not sure how long the test takes to run.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]