-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-17057][ML] ProbabilisticClassifierModels' prediction more reasonable with multi zero thresholds #14643
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
Closed
zhengruifeng
wants to merge
1
commit into
apache:master
from
zhengruifeng:fix_proba_with_threshoulds
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You don't need the check for 0.0 in this case right?
I see the logic of the change, but I wonder what the motivation is for computing a ratio of probabilities here to begin with? I wonder if K-L divergence makes sense here instead:
p*math.log(p/t) + (1-p)*math.log((1-p)/(1-t))@holdenk I believe you added this bit in zhengruifeng@5a23213#diff-4a7c1a2a6f2706d045b694f6d7a054f1R201 ?
As you can see that formula would imply that t > 0 and t < 1. t == 0 means "always predict this", and t == 1 means "never predict this". t == 1 is easy enough to filter out from consideration, though maybe args checking should catch the case that all thresholds are 1 earlier on.
t == 0 is valid if it's true of just one class. That too can be checked when it's specified. If that's the case, of course the class to predict is clear. Otherwise K-L applies.
I wonder if it's worth expanding scope to consider this?
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.
I did add this along with @jkbradley, so this PR says its goal is to make the prediction more reasonable with multiple 0 threshold classes, which I'm wondering if that is a thing that really makes a lot of sense - but I'm certainly open to the idea we could handle thresholds in a different way (although we would certainly want to be careful with any such changes).
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.
Yeah, there are maybe four closely-related issues.
K-L divergence actually gives a different answer. It would rank p=0.5/t=0.2 higher than p=0.3/t=0.1, whereas the current rule is the reverse. I think K-L is more theoretically sound (though someone may tell me there's an equivalent or simpler way to think of it). However that is the most separable question of the 4.
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.
Here's an alternative take on the method that I think addresses all of these:
The significant changes are a slight change in behavior, but also correctly handling the case where no thresholds are exceeded.
really this method should return
Option[Int], but the API isDouble, so the result in this case isNaN. Not ideal but kind of stuck with it.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.
Or, a simpler take is this: if thresholds are just meant to provide a minimum class probability, then the logic should simply be to choose the class with the highest probability that also exceeds its threshold. What about that?