d2_log_loss_score#

sklearn.metrics.d2_log_loss_score(y_true, y_pred, *, sample_weight=None, labels=None)[source]#

\(D^2\) score function, fraction of log loss explained.

Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A model that always predicts the per-class proportions of y_true, disregarding the input features, gets a D^2 score of 0.0.

Read more in the User Guide.

Added in version 1.5.

Parameters:
y_truearray-like or label indicator matrix

The actuals labels for the n_samples samples.

y_predarray-like of shape (n_samples, n_classes) or (n_samples,)

Predicted probabilities, as returned by a classifier’s predict_proba method. If y_pred.shape = (n_samples,) the probabilities provided are assumed to be that of the positive class. The labels in y_pred are assumed to be ordered alphabetically, as done by LabelBinarizer.

sample_weightarray-like of shape (n_samples,), default=None

Sample weights.

labelsarray-like, default=None

If not provided, labels will be inferred from y_true. If labels is None and y_pred has shape (n_samples,) the labels are assumed to be binary and are inferred from y_true.

Returns:
d2float or ndarray of floats

The D^2 score.

Notes

This is not a symmetric function.

Like R^2, D^2 score may be negative (it need not actually be the square of a quantity D).

This metric is not well-defined for a single sample and will return a NaN value if n_samples is less than two.