Skip to content

Implement beta calibration #25552

Open
Open

Description

@e-pet

Describe the workflow you want to enable

It would be nice to implement beta calibration as an additional option in CalibratedClassifierCV.

Describe your proposed solution

Use the implementation provided in https://github.com/betacal/python (MIT license).

Describe alternatives you've considered, if relevant

No response

Additional context

Beta calibration seems like a generally superior alternative to logistic / Platt calibration. See here for further details, paper references, etc.: https://betacal.github.io/ It was proposed in 2017 in two papers by Meelis Kull, Telmo de Menezes e Silva Filho and Peter Flach.

Activity

  1. added
    Needs Triage
    on Feb 6, 2023
  2. lorentzenchr commented on Feb 10, 2023

    @lorentzenchr
    Member

    While the inclusion criteria are, strictly speaking, not (yet) fulfilled, I think that this approach adds value. There are, however, 2 critical questions

  3. e-pet commented on Feb 10, 2023

    @e-pet
    Author

    Ah, sorry - I wasn't aware of the inclusion criteria; those seem sensible. As you probably also saw, the two beta calibration papers together are currently slightly below 200 citations.

    Regarding 1 (where to stop): don't the inclusion criteria precisely say where to stop? I.e., calibration approaches should be i) relatively widely used/cited, and ii) provide clear benefits over existing approaches? Beta calibration seems to check both marks, since it (as I understand it) subsumes logistic regression and is clearly superior in many cases, including the important case of an already well-calibrated model. They have quite extensive experiments in their papers showing the superiority.

    The only other calibration methods that might check these boxes and that I can immediately think of would be BBQ and maybe this more recent method, so I think it's not like you'd be opening the floodgates to dozens of calibration methods. (I might be completely wrong about that, though...)

    Regarding 2: Sure, that makes sense. Should I contact them and ask whether they would like for it to be included here?

    One other thing I just noticed: beta calibration is only specified for the binary classification case. (They do have an equally well-cited extension for the multivariate case, and code is also available for that, but that would probably be a separate discussion.) Both current methods in CalibratedClassifierCV apparently also support the multivariate case. (Cool!) Would it be a problem to add a method that only works in the binary case?

    In any case it's your call, of course, and I also understand if you consider this too experimental / niche.

    To give some background / motivation for this, I was basically just looking for a simple but reasonable calibration method in the low-data regime where isotonic regression is not applicable. Beta calibration seemed an attractive option for this, while LR has significant limitations.

  4. added
    Needs Decision - Include Feature
    and removed
    Needs Triage
    on Feb 24, 2023
  5. perellonieto commented on Jan 22, 2024

    @perellonieto

    As a member of the research group of the Beta calibration paper, allow me to expand on the previous discussion.

    Inclusion criteria: As of today (22/01/2024) both papers are more than 3 years old and have more than 200 citations together [1,2]. To be more precise, the original paper [1] was invited to be extended to the Electronic Journal of Statistics [2]. This is the reason that the citations are split into two papers.

    Current alternative: As one of the main developers of the existing library (https://github.com/betacal/python/) , we would be happy to include our code in scikit-learn. If necessary, I could help with the integration.

    Current calibration methods in scikit-learn: The current methods in scikit-learn (https://scikit-learn.org/stable/modules/generated/sklearn.calibration.CalibratedClassifierCV.html#sklearn.calibration.CalibratedClassifierCV) are sigmoid and isotonic. Sigmoid should be applied only on classification models with infinite support, and isotonic being non-parametric requires more data than Beta calibration (three, two, or even one parameter). Beta calibration could be added using the current implementation of Platt's scaling (we use the scikit-learn implementation of Logistic Regresssion).

    Proposed solution: Include an additional method beta indicating that it is a parametric method that can be used for probabilistic models with finite support (0,1). The method has 3 parameters to be fitted, but we proposed a 2 parameter and 1 parameter version by forcing additional constraints. Given the simplicity of scikit-learn, this could be choosen by an internal cross-validation, or could be a user option.

    Regarding the multiclass setting: The existing methods in scikit-learn (sigmoid and isotonic) and the proposed method beta are all intended to be used in binary classification and are commonly extended to multiclass in a one-vs-the-rest manner with an additional step of normalisation (which is not the correct solution). As a co-author of Dirichlet calibration we would also be happy to add this method for the multiclass case. The method is more than 3 years old and has more than 200 citations [3]. However, I assume this should be discussed in another issue.

    EDIT: Corrected explanation about [2] being published after [1].

    References

    [1] Beta calibration: a well-founded and easily implemented improvement on logistic calibration for binary classifiers M Kull, T Silva Filho, P Flach. Proceedings of the 20th International Conference on Artificial Intelligence and Statistics, PMLR 54:623-631, 2017. (157 citations in Google Scholar)
    [2] Beyond sigmoids: How to obtain well-calibrated probabilities from binary classifiers with beta calibration M Kull, TM Silva Filho, P Flach, Electron. J. Statist. 11 (2) 5052 - 5080, 2017. https://doi.org/10.1214/17-EJS1338SI (86 citations in Google Scholar)
    [3] Beyond temperature scaling: Obtaining well-calibrated multi-class probabilities with dirichlet calibration M Kull, M Perello Nieto, M Kängsepp, T Silva Filho, H Song, P Flach Advances in neural information processing systems 32, 2019 (273 citations in Google Scholar)

  6. lorentzenchr commented on Feb 11, 2024

    @lorentzenchr
    Member

    @scikit-learn/core-devs This meeds a decision.

    Citation-wise, it is a bit on the boundary. I‘m personally inclined to include it as it is statistically sound and „the next best/simplest“ method after the logistic/Platt calibration.

    Sigmoid should be applied only on classification models with infinite support

    @perellonieto Could you explain what you mean? And how it differs from beta calibration?

    As you said, multiclass calibration is best discussed in a new separate issue.

  7. jjerphan commented on Feb 12, 2024

    @jjerphan
    Member

    Is a sklibration package probabl?

  8. GaelVaroquaux commented on Feb 12, 2024

    @GaelVaroquaux
    Member
  9. lorentzenchr commented on Feb 12, 2024

    @lorentzenchr
    Member

    @GaelVaroquaux Could you expand a bit? Do you argue against inclusion?

  10. GaelVaroquaux commented on Feb 12, 2024

    @GaelVaroquaux
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Decision - Include FeatureNew Featuremodule:calibration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions