-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-4256] Make Binary Evaluation Metrics functions defined in cases where there ar... #3118
Conversation
… are 0 positive or 0 negative examples.
Can one of the admins verify this patch? |
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use another variable for brevity?
val totalPositives = c.numTruePositives + c.numFalsePositives
@abull Thanks for noticing this end case! I made some small inline comments. One more: Since end-cases are not well-defined for these types of methods, could you please add comments in the methods' docs about behavior when the denominator is 0? |
Can one of the admins verify this patch? |
Sure, will update the PR. (Hopefully some time today) |
…les; update code formatting per pull request comments
…on functions in test
Cool, I updated the code per the feedback above. |
} | ||
|
||
private def validateMetrics(metrics: BinaryClassificationMetrics, | ||
expectedThresholds: Seq[Double], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use 4-space indentation. We don't use vertical alignment in Spark.
Updated the test code formatting per comments from @mengxr |
ok to test |
test this please |
LGTM. Thank you for checking the corner cases! Waiting for Jenkins ... |
Test build #23292 has started for PR 3118 at commit
|
Test build #23292 has finished for PR 3118 at commit
|
Test PASSed. |
Merged into master and branch-1.2. Thanks! |
…s where there ar... ...e 0 positive or 0 negative examples. Author: Andrew Bullen <andrew.bullen@workday.com> Closes #3118 from abull/master and squashes the following commits: c2bf2b1 [Andrew Bullen] [SPARK-4256] Update Code formatting for BinaryClassificationMetricsSpec 36b0533 [Andrew Bullen] [SYMAN-4256] Extract BinaryClassificationMetricsSuite assertions into private method 4d2f79a [Andrew Bullen] [SPARK-4256] Refactor classification metrics tests - extract comparison functions in test f411e70 [Andrew Bullen] [SPARK-4256] Define precision as 1.0 when there are no positive examples; update code formatting per pull request comments d9a09ef [Andrew Bullen] Make Binary Evaluation Metrics functions defined in cases where there are 0 positive or 0 negative examples. (cherry picked from commit 484fecb) Signed-off-by: Xiangrui Meng <meng@databricks.com>
...e 0 positive or 0 negative examples.