Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

abull
Copy link

@abull abull commented Nov 5, 2014

...e 0 positive or 0 negative examples.

@AmplabJenkins
Copy link

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) {
Copy link
Member

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

@jkbradley
Copy link
Member

@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?

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@abull
Copy link
Author

abull commented Nov 10, 2014

Sure, will update the PR. (Hopefully some time today)

@abull
Copy link
Author

abull commented Nov 10, 2014

Cool, I updated the code per the feedback above.

@jkbradley
Copy link
Member

@abull Thanks for the updates!

LGTM

CC: @mengxr

}

private def validateMetrics(metrics: BinaryClassificationMetrics,
expectedThresholds: Seq[Double],
Copy link
Contributor

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.

@abull
Copy link
Author

abull commented Nov 12, 2014

Updated the test code formatting per comments from @mengxr

@mengxr
Copy link
Contributor

mengxr commented Nov 13, 2014

ok to test

@mengxr
Copy link
Contributor

mengxr commented Nov 13, 2014

test this please

@mengxr
Copy link
Contributor

mengxr commented Nov 13, 2014

LGTM. Thank you for checking the corner cases! Waiting for Jenkins ...

@SparkQA
Copy link

SparkQA commented Nov 13, 2014

Test build #23292 has started for PR 3118 at commit c2bf2b1.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Nov 13, 2014

Test build #23292 has finished for PR 3118 at commit c2bf2b1.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/23292/
Test PASSed.

@mengxr
Copy link
Contributor

mengxr commented Nov 13, 2014

Merged into master and branch-1.2. Thanks!

asfgit pushed a commit that referenced this pull request Nov 13, 2014
…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>
@asfgit asfgit closed this in 484fecb Nov 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants