@@ -1033,6 +1033,65 @@ set [0,1] has an error: ::
1033
1033
for an example of zero one loss usage to perform recursive feature
1034
1034
elimination with cross-validation.
1035
1035
1036
+ .. _brier_score_loss :
1037
+
1038
+ Brier score loss
1039
+ ----------------
1040
+
1041
+ The :func: `brier_score_loss ` function computes the
1042
+ `Brier score <https://en.wikipedia.org/wiki/Brier_score >`_
1043
+ for binary classes. Quoting Wikipedia:
1044
+
1045
+ "The Brier score is a proper score function that measures the accuracy of
1046
+ probabilistic predictions. It is applicable to tasks in which predictions
1047
+ must assign probabilities to a set of mutually exclusive discrete outcomes."
1048
+
1049
+ This function returns a score of the mean square difference between the actual
1050
+ outcome and the predicted probability of the possible outcome. The actual
1051
+ outcome has to be 1 or 0 (true or false), while the predicted probability of
1052
+ the actual outcome can be a value between 0 and 1.
1053
+
1054
+ The brier score loss is also between 0 to 1 and the lower the score (the mean
1055
+ square difference is smaller), the more accurate the prediction is. It can be
1056
+ thought of as a measure of the "calibration" of a set of probabilistic
1057
+ predictions.
1058
+
1059
+ .. math ::
1060
+
1061
+ BS = \frac {1 }{N} \sum _{t=1 }^{N}(f_t - o_t)^2
1062
+
1063
+ where : :math: `N` is the total number of predictions, :math: `f_t` is the
1064
+ predicted probablity of the actual outcome :math: `o_t`.
1065
+
1066
+ Here is a small example of usage of this function:::
1067
+
1068
+ >>> import numpy as np
1069
+ >>> from sklearn.metrics import brier_score_loss
1070
+ >>> y_true = np.array([0, 1, 1, 0])
1071
+ >>> y_true_categorical = np.array(["spam", "ham", "ham", "spam"])
1072
+ >>> y_prob = np.array([0.1, 0.9, 0.8, 0.4])
1073
+ >>> y_pred = np.array([0, 1, 1, 0])
1074
+ >>> brier_score_loss(y_true, y_prob)
1075
+ 0.055
1076
+ >>> brier_score_loss(y_true, 1-y_prob, pos_label=0)
1077
+ 0.055
1078
+ >>> brier_score_loss(y_true_categorical, y_prob, pos_label="ham")
1079
+ 0.055
1080
+ >>> brier_score_loss(y_true, y_prob > 0.5)
1081
+ 0.0
1082
+
1083
+
1084
+ .. topic :: Example:
1085
+
1086
+ * See :ref: `example_calibration_plot_calibration.py `
1087
+ for an example of Brier score loss usage to perform probability
1088
+ calibration of classifiers.
1089
+
1090
+ .. topic :: References:
1091
+
1092
+ * G. Brier, `Verification of forecasts expressed in terms of probability
1093
+ <http://docs.lib.noaa.gov/rescue/mwr/078/mwr-078-01-0001.pdf> `_,
1094
+ Monthly weather review 78.1 (1950)
1036
1095
1037
1096
.. _multilabel_ranking_metrics :
1038
1097
0 commit comments