-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Description
I've seen these already closed issues (and probably there are more):
about the behavior of prec/rec/f1 when both predictions and ground truth are all negatives. See for some discussion about the topic
My opinion is that sklearn should be flexible about this. I agree with having a default behavior of returning 0 + warning, but I would like to have the option to say: For these special cases, if the true positives, false positives and false negatives are all 0, the precision, recall and F1-measure are 1.
I use this in my day-to-day and atm I have a wrapper around these scorers to force this. It's not exactly the same scenario but to simplify assume you're doing named entity recognition (with one entity to make it easy) and want to apply f1-score to each document, and then average them. If a document has no entities and your model gives no entities you would like a perfect score. Unfortunately, the current sklearn scores don't allow you to do that
This is a proposal, and I can do the PR if people here find it useful. My idea is to add a parameter to these scorers so that the default is to raise a warning (and return 0), and the user can set to new modes:
a) raise an error
b) warning + return 1
Please let me know your thoughts