8000 Add Brier_score_loss to model validation doc · scikit-learn/scikit-learn@20ff083 · GitHub
[go: up one dir, main page]

Skip to content

Commit 20ff083

Browse files
committed
Add Brier_score_loss to model validation doc
1 parent d161bfa commit 20ff083

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

doc/modules/model_evaluation.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,47 @@ set [0,1] has an error: ::
10331033
for an example of zero one loss usage to perform recursive feature
10341034
elimination with cross-validation.
10351035

1036+
.. _brier_score_loss:
1037+
1038+
Brier score loss
1039+
----------------
1040+
1041+
The :func:`brier_score_loss` function returns a score of the mean square difference
1042+
between the actual outcome and the predicted probability of the possible outcome.
1043+
The actual outcome has to be 1 or 0 (true or false), while the predicted probability
1044+
of the actual outcome happens can be value between 0 and 1. The brier score loss is
1045+
also between 0 to 1 and the lower the score (the mean square difference is smaller),
1046+
the more accurate the prediction is.
1047+
1048+
.. math::
1049+
1050+
BS = \frac{1}{N} \sum_{t=1}^{N}(f_t - o_t)^2
1051+
1052+
where : :math:`N` is the total number of predictions, :math:`f_t` is the predicted
1053+
probablity of the actual outcome :math:`o_t`
1054+
1055+
>>> import numpy as np
1056+
>>> from sklearn.metrics import brier_score_loss
1057+
>>> from sklearn.metrics import zero_one_loss
1058+
>>> y_true = np.array([0, 1, 1, 0])
1059+
>>> y_true_categorical = np.array(["spam", "ham", "ham", "spam"])
1060+
>>> y_prob = np.array([0.1, 0.9, 0.8, 0.4])
1061+
>>> y_pred = np.array([0, 1, 1, 0])
1062+
>>> brier_score_loss(y_true, y_prob) # doctest: +ELLIPSIS
1063+
0.055
1064+
>>> zero_one_loss(y_true, y_pred, normalize=False)
1065+
0
1066+
>>> brier_score_loss(y_true, 1-y_prob, pos_label=0) # doctest: +ELLIPSIS
1067+
0.055
1068+
>>> brier_score_loss(y_true_categorical, y_prob, pos_label="ham") # doctest: +ELLIPSIS
1069+
0.055
1070+
>>> brier_score_loss(y_true, np.array(y_prob) > 0.5)
1071+
0.055
1072+
1073+
.. topic:: Example:
1074+
1075+
* See :ref:`example_calibration_plot_calibration.py`
1076+
for an example of Brier score loss usage to perform probability calibration of classifiers.
10361077

10371078
.. _multilabel_ranking_metrics:
10381079

0 commit comments

Comments
 (0)
0