Skip to content
Back to skills

D2 Brier Score

ASecurity

Compute the d2_brier_score metric — provided by scikit-learn. Use when the user has predictions and ground-truth and needs to compute d2_brier_score, or asks how to score with d2_brier_score.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 11, 2026
documentationpython

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add qhjqhj00/research-skills-pool --skill d2-brier-score --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of D2 Brier Score?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for D2 Brier Score
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qhjqhj00-d2-brier-score/badge)](https://www.skillsdirectory.com/skills/qhjqhj00-d2-brier-score)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: d2-brier-score
description: Compute the d2_brier_score metric — provided by scikit-learn. Use when the user has predictions and ground-truth and needs to compute d2_brier_score, or asks how to score with d2_brier_score.
metadata:
  skill_kind: metric
  source_lib: scikit-learn
  import_path: sklearn.metrics.d2_brier_score
  source: library_introspection
---

# d2-brier-score

> Metric `d2_brier_score` from `scikit-learn` (sklearn.metrics.d2_brier_score)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with d2_brier_score, or
mentions `sklearn.metrics.d2_brier_score` directly, or wants the standard scikit-learn implementation.

## Reference signature

```python
from sklearn.metrics import d2_brier_score

# d2_brier_score(y_true, y_proba, *, sample_weight=None, pos_label=None, labels=None)
```

## Library docstring

```
:math:`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 :ref:`User Guide <d2_score_classification>`.

Parameters
----------
y_true : array-like of shape (n_samples,)
    True targets.

y_proba : array-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. If `y_proba.shape = (n_samples, n_classes)`
    the columns in `y_proba` are assumed to correspond to the
    labels in alphabetical order, as done by
    :class:`~sklearn.preprocessing.LabelBinarizer`.

sample_weight : array-like of shape (n_samples,), default=None
    Sample weights.

pos_label : int, 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 and
      `pos_label` should be explicitly specified;
    * otherwise, `pos_label` defaults to the greater label,
      i.e. `np.unique(y_true)[-1]`.

labels : array-like of shape (n_classes,), default=None
    Class labels when `y_proba.shape = (n_samples, n_classes)`.
    If not provided, labels will be inferred from `y_true`.

Returns
-------
d2 : float
    The D^2 score.

References
----------
.. [1] `Wikipedia entry for the Brier Skill Score (BSS)
        <https://en.wikipedia.org/wiki/Brier_score>`_.
```

## Quick recipe

```python
import sklearn.metrics as _m
score = _m.d2_brier_score(y_true, y_pred)
```

## Don'ts

- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.