imatiach-msft commented on a change in pull request #17084:
[SPARK-24103][ML][MLLIB] ML Evaluators should use weight column - added weight
column for binary classification evaluator
URL: https://github.com/apache/spark/pull/17084#discussion_r259666719
##########
File path:
mllib/src/test/scala/org/apache/spark/mllib/evaluation/BinaryClassificationMetricsSuite.scala
##########
@@ -82,6 +82,34 @@ class BinaryClassificationMetricsSuite extends
SparkFunSuite with MLlibTestSpark
validateMetrics(metrics, thresholds, rocCurve, prCurve, f1, f2,
precisions, recalls)
}
+ test("binary evaluation metrics with weights") {
+ val w1 = 1.5
+ val w2 = 0.7
+ val w3 = 0.4
+ val scoreAndLabelsWithWeights = sc.parallelize(
+ Seq((0.1, 0.0, w1), (0.1, 1.0, w2), (0.4, 0.0, w1), (0.6, 0.0, w3),
+ (0.6, 1.0, w2), (0.6, 1.0, w2), (0.8, 1.0, w1)), 2)
+ val metrics = new BinaryClassificationMetrics(scoreAndLabelsWithWeights, 0)
+ val thresholds = Seq(0.8, 0.6, 0.4, 0.1)
+ val numTruePositives =
+ Seq(1.0 * w1, 1.0 * w1 + 2.0 * w2, 1.0 * w1 + 2.0 * w2, 3.0 * w2 + 1.0 *
w1)
Review comment:
Yep, 1.0 is for clarity. Changed to int instead of double.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]