@@ -184,7 +184,7 @@ class ImputerSuite extends MLTest with DefaultReadWriteTest {
184184 (1 , 11.0 , 11.0 , 11.0 ),
185185 (2 , 3.6 , 3.6 , 3.6 ),
186186 (3 , Double .NaN , 5.2 , 3.6 )
187- )).toDF(" id" , " value1" , " expected_mean_value1 " , " expected_median_value1 " )
187+ )).toDF(" id" , " value1" , " expected_mean_value1_double " , " expected_median_value1_double " )
188188
189189 val imputer = new Imputer ()
190190 .setInputCols(Array (" value1" ))
@@ -198,11 +198,10 @@ class ImputerSuite extends MLTest with DefaultReadWriteTest {
198198 val df2 = df.withColumn(" value1" , col(" value1" ).cast(mType))
199199 .withColumn(" value1" , when(col(" value1" ).equalTo(0 ), null ).otherwise(col(" value1" )))
200200
201-
202201 Seq (" mean" , " median" ).foreach { strategy =>
203202 imputer.setStrategy(strategy)
204- val model = imputer.fit(df )
205- val resultDF = model.transform(df )
203+ val model = imputer.fit(df2 )
204+ val resultDF = model.transform(df2 )
206205
207206 imputer.getInputCols.zip(imputer.getOutputCols).foreach { case (inputCol, outputCol) =>
208207
@@ -212,8 +211,9 @@ class ImputerSuite extends MLTest with DefaultReadWriteTest {
212211 assert(inputType === outputType, " Output type is not the same as input type." )
213212
214213 // check value
215- val expectedDoubleColumn = s " texpected_ ${strategy}_ $inputCol"
216- resultDF.select(col(expectedDoubleColumn), col(outputCol).cast(DoubleType ))
214+ val expectedDoubleColumn = s " expected_ ${strategy}_ ${inputCol}_double "
215+ resultDF.select(col(expectedDoubleColumn).cast(mType).cast(DoubleType ),
216+ col(outputCol).cast(DoubleType ))
217217 .collect().foreach {
218218 case Row (exp : Double , out : Double ) =>
219219 assert((exp.isNaN && out.isNaN) || (exp ~== out absTol 1e-5 ),
0 commit comments