Repository navigation
FEA: Calibration Error - #11096
FEA: Calibration Error#11096samronsin wants to merge 115 commits into
Conversation
jnothman
left a comment
There was a problem hiding this comment.
You will also need to update:
doc/modules/classes.rstdoc/modules/model_evaluation.rstsklearn/metrics/tests/test_common.py
jnothman
left a comment
There was a problem hiding this comment.
Should this be available as a scorer for cross validation? Should it be available for CalibratedClassifierCV?
|
You don't need to test sample weights as the common tests will |
|
I'm not sure if it makes sense to have this as a ready-made scorer, and so I might want to hold out on that? It should probably be mentioned in the calibration docs and examples. |
|
Can you maybe also add https://www.math.ucdavis.edu/~saito/data/roc/ferri-class-perf-metrics.pdf to the references and maybe include some of the discussion there about this loss? In particular, this is one of two calibration losses they discuss, so maybe we should be more specific with the name? |
|
Actually I did not implement any of the losses from the paper you mention @amueller, as I take non-overlapping bins instead of sliding window in CalB.
|
|
I ended up implementing the calB loss suggested by @amueller, but did not provide support for sample weights. |
jnothman
left a comment
There was a problem hiding this comment.
Sorry for fashion again not being in a situation to review the main content...
| 'balanced_accuracy' :func:`metrics.balanced_accuracy_score` for binary targets | ||
| 'average_precision' :func:`metrics.average_precision_score` | ||
| 'brier_score_loss' :func:`metrics.brier_score_loss` | ||
| 'calibration_loss' :func:`metrics.calibration_loss` |
There was a problem hiding this comment.
to respect the convention higher is better we should maybe call it
neg_calibration_error
thoughts anyone?
There was a problem hiding this comment.
Yes for the grid search tools in scikit-learn will always to maximize the scoring criterion. If the criterion is derived from a loss to minimize we instead maximize the the negative criterion. It's important to name it accordingly to make the column names and column values of pd.DataFrame(grid_search.cv_results_) consistent.
There was a problem hiding this comment.
We might also want to provide standard aliases neg_max_calibration_error and neg_expected_calibration_error to set the norm parameter to make it possible to grid search for the ECE or MCE metrics traditionally used in the literature.
…debias term for l2 norm
|
Salut @samronsin ;) Thanks a lot for the PR ! We had a lot of discussions recently, before and during the scikit-learn sprint, on the "best" estimate for the calibration error. Based on the analyses reported here and IRL discussions with @ogrisel @lorentzenchr we currently think that:
I would say your PR is quite close with the following modifications:
Please ping me if you're willing to work on this or if you need a review. |
|
Salut @antoinebaker, good to read you 🙂 ! Thank you for your message and suggestions. This makes a lot of sense, let's break this PR into smaller scoped PRs ! I'll start by extracting the |
|
Closing as superseded by #34261 (and follow-ups). |
This PR implements calibration errors for binary classifiers, namely:
norm = 'max'from Guo et al. On Calibration of Modern Neural Networks (2017)norm = 'l1'also from Guo et al. On Calibration of Modern Neural Networks (2017) as requested in Feature Request: function to calculate Expected Calibration Error (ECE) #18268norm = 'l2'from Verified Uncertainty Calibration. Ananya Kumar, Percy Liang, Tengyu Ma (2019) with the optional bias correction term asdebias = True.See initial discussion on issue #10883
Closes #18268