Skip to content

Incorrect interpretation of Brier score loss in docstring  #10883

Closed

Description

@samronsin

Therefore, the lower the Brier score is for a set of predictions, the

Therefore, the lower the Brier score is for a set of predictions, the better the predictions are calibrated.

As far as I can tell, this claim is incorrect (also incorrect in the Wikipedia entry cited) and should be deleted or detailed (one component of the two-term decomposition of the Brier score does assess calibration).

Here's a counter-example on a dataset with 12 points and 2 estimators.

model A model B y
0.00 0.00 0
0.25 0.25 0
0.25 0.25 0
0.25 0.25 0
0.25 0.75 1
0.50 0.50 0
0.50 0.50 1
0.75 0.25 0
0.75 0.75 1
0.75 0.75 1
0.75 0.75 1
1.00 1.00 1

Brier scores:

model A model B
0.166666666667 0.0833333333333

Calibration curves:

image

Activity

  1. jnothman commented on Mar 28, 2018

    @jnothman
    Member

    I'm not familiar enough with this to evaluate it. Why do you consider model B a worse calibration? Can you find literature that makes a similar critique, or more clearly defines what calibration means?

  2. ericjam3 commented on Mar 29, 2018

    @ericjam3

    I am looking to help with this project, but am having troubles getting the build to work properly. I am having particular difficulty with Atlas and Openblas. Where can I get some assisstance on this? Thanks!

  3. lesteve commented on Mar 29, 2018

    @lesteve
    Member

    @ericjam3 first search in the issues for a similar problem. If that does not solve your problem, open a new issue with the command you ran and the full error you get. An alternative is to ask on the mailing list: [email protected].

    In general try to refrain from commenting in an issue if it is not 95% clear that your problem is related to its first post.

  4. samronsin commented on Mar 29, 2018

    @samronsin
    ContributorAuthor

    Quoting from The well-calibrated Bayesian, A.P. Dawid, Journal of the American Statistical Association, 1982:

    Suppose that a forecaster sequentially assigns probabilities to events. He is well calibrated if, for example, of those events to which he assigns a probability 30 percent, the long-run proportion that actually occurs turns out to be 30 percent.

    In the example model A is well calibrated for all the predicted probabilities (0, 0.25, 0.5, 0.75 and 1) but model B is not well calibrated for probabilities 0.25 and 0.75 as 100% of predicted 0.25 (resp. 0.75) are in output class 0 (resp. 1), instead of 75%.

  5. jnothman commented on Mar 29, 2018

    @jnothman
    Member
  6. samronsin commented on Mar 29, 2018

    @samronsin
    ContributorAuthor

    The Brier score can be decomposed as the sum of a calibration loss and a refinement loss (referred to as the "two-component decomposition" in the Wikipedia entry). The refinement measures the ability to distinguish between the classes across threshold bins. The best case for refinement is for all threshold bins the classes proportion is 100%-0%, and in the worst case the proportion is always 50%-50%.

    So the following claim would be correct:

    The Brier score can be decomposed as the sum of calibration and refinement losses, where the refinement loss measures the ability of the model to distinguish between the classes across threshold bins. Therefore, assuming equal refinement, the lower the Brier score is for a set of predictions, the better the predictions are calibrated.

  7. lesteve commented on Mar 29, 2018

    @lesteve
    Member

    I think that what you are saying makes sense. To minimize the briere_loss you want something that is a Heaviside function which is not the same as a well-calibrated classifier for which you want to be along the diagonal (if your classifier says proba=0.25, you want that 25% of your samples are actual ones that are misclassified as zeroes).

    It seems like the primary motivation for introducing briere_score_loss was to judge the calibration of classifiers though. For example, this documentation page says: "The calibration performance is evaluated with Brier score brier_score_loss, reported in the legend (the smaller the better)."

    @samronsin what would be a better measure to judge the calibration of a classifier?

  8. lesteve commented on Mar 29, 2018

    @lesteve
    Member

    ping @jmetzen and @agramfort who were involved in #1176.

  9. samronsin commented on Mar 29, 2018

    @samronsin
    ContributorAuthor

    The calibration loss that we would want to minimize should be roughly:

    def calibration_loss(y_true, y_pred, step_size=1e-2):
        loss = 0.0
        for x in np.arange(0, 1, step_size):
            in_range = (x < y_pred) & (y_pred < x + step_size)
            count = in_range.sum()
            avg_pred_1 = (in_range * y_true).sum() / float(count)
            delta_loss = count * (avg_pred_1 - x)**2
            loss += 0. if np.isnan(delta_loss) else delta_loss
        loss /= y_pred.shape[0]
        return loss

    To avoid several (1/step_size) sequential full passes on the data it could be parallelized and / or y_pred could be sorted.

  10. amueller commented on Apr 5, 2018

    @amueller
    Member

    I was thinking about this recently and yes, adding a calibration loss would be nice. There are several definitions. Some are using just the distance in the calibration curve (I think that's @samronsin's version).
    This paper has some discussion:
    https://www.math.ucdavis.edu/~saito/data/roc/ferri-class-perf-metrics.pdf

    This paper has the definition of a more refined calibration loss based on the ROC curve:
    https://pdfs.semanticscholar.org/7618/8dba4c840c638642cdbaa8fb196ec83cac16.pdf
    (CalL in the paper above, while the code by @samronsin is CalB, I think).

  11. aishgrt1 commented on Apr 12, 2018

    @aishgrt1
    Contributor

    PR has been created for this. #10964

  12. jmetzen commented on Apr 13, 2018

    @jmetzen
    Member

    Two further metrics relevant in the context of calibration are Expected Calibration Error (ECE) and Maximum Calibration Error (MCE) as proposed and used in the following papers:

    Naeini, Mahdi Pakdaman, Cooper, Gregory F, and Hauskrecht, Milos. Obtaining well calibrated probabilities using bayesian binning. In AAAI, pp. 2901, 2015.
    https://people.cs.pitt.edu/~milos/research/AAAI_Calibration.pdf

    Chuan Guo, Geoff Pleiss, Yu Sun, Kilian Q. Weinberger, On Calibration of Modern Neural Networks
    https://arxiv.org/abs/1706.04599

  13. 53X commented on Apr 22, 2018

    @53X

    @jmetzen can I take this challenge of coding up the ECE and MCE as proposed by the papers given above?

  14. jmetzen commented on Apr 23, 2018

    @jmetzen
    Member

    sure, that would be great @53X !

  15. samronsin commented on May 15, 2018

    @samronsin
    ContributorAuthor

    Thanks for the references @amueller and @jmetzen ! I ended up implementing ECE and MCE from "Chuan Guo, Geoff Pleiss, Yu Sun, Kilian Q. Weinberger, On Calibration of Modern Neural Networks" in PR #11096.
    Sorry @53X I didn't see that you were also interested in working on this. Let me know if you want to compare notes !

  16. ogrisel commented on Jun 10, 2020

    @ogrisel
    Member

    Reopening as #11096 is about implementing an alternative to Brier score but the Brier score docstring still needs to be fixed.

  17. ogrisel commented on Jun 10, 2020

    @ogrisel
    Member

    Actually I was confused. This was fixed in #10969.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions