Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/10472#discussion_r49029265
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/evaluation/BinaryClassificationEvaluatorSuite.scala
---
@@ -36,4 +37,35 @@ class BinaryClassificationEvaluatorSuite
.setMetricName("areaUnderPR")
testDefaultReadWrite(evaluator)
}
+
+ test("should accept both vector and double raw prediction col") {
+ val evaluator = new BinaryClassificationEvaluator()
+ .setMetricName("areaUnderPR")
+
+ val vectorDF = sqlContext.createDataFrame(Seq(
+ (0d, Vectors.dense(12, 2.5)),
+ (1d, Vectors.dense(1, 3)),
+ (0d, Vectors.dense(10, 2))
+ )).toDF("label", "rawPrediction")
+ assert(evaluator.evaluate(vectorDF) === 1.0)
+
+ val doubleDF = sqlContext.createDataFrame(Seq(
+ (0d, 0d),
+ (1d, 1d),
+ (0d, 0d)
+ )).toDF("label", "rawPrediction")
+ assert(evaluator.evaluate(doubleDF) === 1.0)
+
+ val stringDF = sqlContext.createDataFrame(Seq(
+ (0d, "0.0d"),
+ (1d, "1.0d"),
+ (0d, "0.0d")
+ )).toDF("label", "rawPrediction")
+ val thrown = intercept[IllegalArgumentException] {
+ evaluator.evaluate(stringDF)
+ }
+ assert(thrown.getMessage contains "Column rawPrediction must be of
type equals to one of the " +
--- End diff --
How about something like this to be more robust to formatting changes?
```
assert(thrown.getMessage.replace("\n", "") contains ...)
```
---
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]