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_r255805007
##########
File path:
mllib/src/main/scala/org/apache/spark/mllib/evaluation/binary/BinaryClassificationMetricComputers.scala
##########
@@ -27,33 +27,33 @@ private[evaluation] trait
BinaryClassificationMetricComputer extends Serializabl
/** Precision. Defined as 1.0 when there are no positive examples. */
private[evaluation] object Precision extends
BinaryClassificationMetricComputer {
override def apply(c: BinaryConfusionMatrix): Double = {
- val totalPositives = c.numTruePositives + c.numFalsePositives
+ val totalPositives = c.weightedTruePositives + c.weightedFalsePositives
if (totalPositives == 0) {
1.0
} else {
- c.numTruePositives.toDouble / totalPositives
+ c.weightedTruePositives.toDouble / totalPositives
}
}
}
/** False positive rate. Defined as 0.0 when there are no negative examples. */
private[evaluation] object FalsePositiveRate extends
BinaryClassificationMetricComputer {
override def apply(c: BinaryConfusionMatrix): Double = {
- if (c.numNegatives == 0) {
+ if (c.weightedNegatives == 0) {
0.0
} else {
- c.numFalsePositives.toDouble / c.numNegatives
+ c.weightedFalsePositives.toDouble / c.weightedNegatives
}
}
}
/** Recall. Defined as 0.0 when there are no positive examples. */
private[evaluation] object Recall extends BinaryClassificationMetricComputer {
override def apply(c: BinaryConfusionMatrix): Double = {
- if (c.numPositives == 0) {
+ if (c.weightedPositives == 0) {
Review comment:
done!
----------------------------------------------------------------
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]