-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-17057] [ML] ProbabilisticClassifierModels' prediction more reasonable with multi zero thresholds #14949
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
Conversation
…lasses can only be predicted if they exceed their threshold (meaning no class may be predicted), and otherwise ordering by highest probability, then lowest threshold, then by class index
|
Test build #64900 has finished for PR 14949 at commit
|
|
Test build #64903 has finished for PR 14949 at commit
|
|
@jkbradley @zhengruifeng @MLnick I wonder if I could ask you for comments on this change? it's a behavior change, so not something I'd do lightly, but I do think it improves the semantics here. |
|
I think both this change and current design are reasonable. And I personally prefer to current one which treat threshould as a kind of weight. |
|
The problem is that it's called 'threshold' and not 'weight', and 'threshold' means something different. Is anyone suggesting that it was always meant as a 'weight', and/or has a reference for this type of weighting? I've never seen it ... not sure what multiplying a probability by 1/weight would mean theoretically. Note this change would also make threshold matter as a tie-breaker. |
|
The original JIRA SPARK-8069 refers to https://cran.r-project.org/web/packages/randomForest/randomForest.pdf. That R package calls it "cutoff". Though it does indeed seem to act more like a "weight" or "scaling". I can't say I've come across it before, and it appears this is the only package that does it like this (at least that I've been able to find from some quick searching). I haven't found any theoretical background for it either. In any case, now that we have it, I think it probably best to keep it as is. However, It appears that our implementation here is flawed since in the original R code, the So:
I believe this takes care of the edge cases since no thresholds can be I don't like returning |
|
Oh, I get it now. That makes sense. If this were being applied to decision trees only, that would make sense and we could fix this up and document the meaning. I agree it only makes sense to return "no class" if actually thresholding. The only problem here is that this is not being applied just to a random forest implementation but to all classifiers that output a probability. That's a little more of a stretch. I suppose the result here can be thought of as a likelihood ratio of class probability vs prior, not some hacky heuristic specific to the CRAN package. I think the name is unfortunate because I would not have guessed that's the meaning given the name (though to be fair the scaladoc does say what it means). I'll close this but what's the best way forward? Option 1. Option 2. Option 3. |
What changes were proposed in this pull request?
See related discussion at #14643
This actually changes more than what the original JIRA encompassed, but does propose a more reasonable (?) and deterministic result in this and other corner cases.
Revise semantics of ProbabilisticClassifierModel thresholds so that classes can only be predicted if they exceed their threshold (meaning no class may be predicted), and otherwise ordering by highest probability, then lowest threshold, then by class index.
How was this patch tested?
Existing and new unit tests.