d2_brier_score#
- sklearn.metrics.d2_brier_score(y_true, y_proba, *, sample_weight=None, pos_label=None, labels=None)[source]#
\(D^2\) score function, fraction of Brier score explained.
Best possible score is 1.0 and it can be negative because the model can be arbitrarily worse than the null model. The null model, also known as the optimal intercept model, is a model that constantly predicts the per-class proportions of
y_true
, disregarding the input features. The null model gets a D^2 score of 0.0.Read more in the User Guide.
- Parameters:
- y_truearray-like of shape (n_samples,)
True targets.
- y_probaarray-like of shape (n_samples,) or (n_samples, n_classes)
Predicted probabilities. If
y_proba.shape = (n_samples,)
the probabilities provided are assumed to be that of the positive class. Ify_proba.shape = (n_samples, n_classes)
the columns iny_proba
are assumed to correspond to the labels in alphabetical order, as done byLabelBinarizer
.- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
- pos_labelint, float, bool or str, default=None
Label of the positive class.
pos_label
will be inferred in the following manner:if
y_true
in {-1, 1} or {0, 1},pos_label
defaults to 1;else if
y_true
contains string, an error will be raised andpos_label
should be explicitly specified;otherwise,
pos_label
defaults to the greater label, i.e.np.unique(y_true)[-1]
.
- labelsarray-like of shape (n_classes,), default=None
Class labels when
y_proba.shape = (n_samples, n_classes)
. If not provided, labels will be inferred fromy_true
.
- Returns:
- d2float
The D^2 score.
References