Github user BenFradet commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17384#discussion_r108224092
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/regression/IsotonicRegressionSuite.scala
 ---
    @@ -189,6 +191,47 @@ class IsotonicRegressionSuite
             assert(expected.predictions === actual.predictions)
           }
       }
    +
    +  test("Besides VectorUDT, should support all NumericType features, and 
not support other types") {
    +    val df = generateIsotonicInput(Seq(1, 2, 3))
    +    val ir = new IsotonicRegression()
    +
    +    val expected = ir.fit(df)
    +    val expectedPrediction =
    +      
expected.transform(df).select("prediction").map(_.getDouble(0)).collect()
    +
    +    val types =
    +      Seq(ShortType, LongType, IntegerType, FloatType, ByteType, 
DoubleType, DecimalType(10, 0))
    +
    +    types.foreach { t =>
    +      val df2 = df.select(col("label"), col("features").cast(t), 
col("weight"))
    +
    +      val actual = ir.fit(df2)
    +      assert(expected.boundaries === actual.boundaries)
    +      assert(expected.predictions === actual.predictions)
    +
    +      val actualPrediction =
    +        
actual.transform(df2).select("prediction").map(_.getDouble(0)).collect()
    +      assert(expectedPrediction === actualPrediction)
    +    }
    +
    +    val dfWithStringFeatures =
    +      df.select(col("label"), col("features").cast(StringType), 
col("weight"))
    +
    +    val thrown = intercept[IllegalArgumentException] {
    +      ir.fit(dfWithStringFeatures)
    +    }
    +    assert(thrown.getMessage.contains(
    +      "Column features must be of type NumericType or VectorUDT," +
    +        " but was actually of type StringType"))
    +
    +    val thrown2 = intercept[IllegalArgumentException] {
    +      expected.transform(dfWithStringFeatures)
    +    }
    +    assert(thrown2.getMessage.contains(
    +      "Column features must be of type NumericType or VectorUDT," +
    +        " but was actually of type StringType"))
    +  }
    --- End diff --
    
    Why not use [MLTestingUtil's 
checkNumericTypes](https://github.com/apache/spark/blob/master/mllib/src/test/scala/org/apache/spark/ml/util/MLTestingUtils.scala#L41-L88)?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to