Repository navigation
Description
Describe the workflow you want to enable
As per Brier score User Guide:
“Only when refinement loss remains the same does a lower Brier score loss always mean better calibration”
But the current API doesn't provide refinement loss/calibration loss.
Which makes it hard to measure the quality of probabilistic estimates.
Describe your proposed solution
My proposed solution involves implementing the one described in the paper [Flach2008]
, the reference which is conveniently already mentioned in the User Guide
Namely, estimating Calibration loss and Refinement loss without any binning, on raw data/predictions.
If the community decides this is a valuable addition, I humbly present my implementation, which is WIP in terms of Scikit-Learn codebase conventions compliance and corner case processing, but is functioning in essence.
Describe alternatives you've considered, if relevant
Visual comparison of calibration curves
<not exact, not scalable
Making custom ad hoc metrics to estimate probability errors
<fragile, dubious
Using sklearn.calibration.calibration_curve
<requires binning1
Using #11096
<requires binning1
1 Now, problem with binning is described in [Bella2012]. To quote:
The problem of using bins is that if too few bins are defined, the real probabilities are
not properly detailed to give an accurate evaluation. If too many bins are defined, the real
probabilities are not properly estimated. A partial solution to this problem is to make the bins
overlap.
And using overlapping bins seems like and additional degree of freedom, additional parameter one'd have to keep in mind, tune and argue about with collegues.
Additional context
I'm aware that contributors to #11096 have done work in implementing Calibration loss with binning and clarifying docs on calibration topic in general. So I'd like to get feedback on that and I'm open to suggestions how to proceed.
Activity
ogrisel commentedon May 17, 2022
There is a related proposal by @lorentzenchr to implement binless calibration curves using CORP method and the PAV / istonic regression aglorithm in #23132. The paper linked in this issue also proposes an estimate of a decomposition of the Brier score into 3 terms: miscalibration, refinement / discrimination and irreducible Brier loss.
I still need to read all those papers in details to get a clear understanding on how they relate to decide what should be done in scikit-learn.
ogrisel commentedon May 17, 2022
@ColdTeapot273K @lorentzenchr if you already have a good understanding of both approaches, I would love you to share your analysis of the pros and cons of each.
lorentzenchr commentedon Jun 21, 2022
In the end, every method uses bins, but they differ in its construction.
The CORP approach, however, has clearly stated beneficial properties and is generic in that it can be used on probabilistic classification and regression problems which enables a general solution to score decompositions.
ColdTeapot273K commentedon Jun 21, 2022
@lorentzenchr I'm not sure I can fully agree on "every method here uses bins".
This implementation kinda pools similar predictions into the same "bucket" indeed, but that "bucket" is the exact number and not an interval (conceptually at least; i omit the problems of floating point arithmetics and epsilon). Binning implies discretization and here no discretization is performed, it operates on continuous values (the key point).
Also could you clarify what do you refer to as "CORP approach" (didn't see references mentioning that in the triaging PR thread) and what do you refer to as "clearly states beneficial properties" and how are they ultimately more beneficial than the benefits of the exaxct/binless implementation, which I mention here? if that's your point
If you insist that there certainly are practical benefits to binned implementation ...
(vs exact impl or vs binning
pred_probaoutputs and supplying them to the exact impl and thus having binned by user whatever way they like)... then, as an engineer it makes sense to me to use a
strategypattern (inside one function) to allow a user to switch between exact/binned logics, the same way we switch betweenl1andl2or between different optimizers/solvers for an estimator. How about that?lorentzenchr commentedon Jun 27, 2022
See #21774 (comment), arxiv link is https://arxiv.org/abs/2008.03033.
This issue will be solved if we solve the broader (but not much more difficult) #23767.
lorentzenchr commentedon Feb 26, 2023
For those interested, this is now available in the new package model-diagnostics as
Note that the Brier score is the squared error, just a different name.