Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/3118#discussion_r19986239
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/evaluation/binary/BinaryClassificationMetricComputers.scala
---
@@ -27,19 +27,31 @@ private[evaluation] trait
BinaryClassificationMetricComputer extends Serializabl
/** Precision. */
private[evaluation] object Precision extends
BinaryClassificationMetricComputer {
override def apply(c: BinaryConfusionMatrix): Double =
- c.numTruePositives.toDouble / (c.numTruePositives +
c.numFalsePositives)
+ if (c.numTruePositives + c.numFalsePositives == 0) {
+ 0.0
+ } else {
+ c.numTruePositives.toDouble / (c.numTruePositives +
c.numFalsePositives)
+ }
}
/** False positive rate. */
private[evaluation] object FalsePositiveRate extends
BinaryClassificationMetricComputer {
override def apply(c: BinaryConfusionMatrix): Double =
--- End diff --
Scala style (braces):
```
override def apply(c: BinaryConfusionMatrix): Double = {
if (c.numNegatives == 0) {
0.0
} else {
c.numFalsePositives.toDouble / c.numNegatives
}
}
```
---
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]