Skip to content
Back to skills

Mean Tweedie Deviance

ASecurity

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

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

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add qhjqhj00/research-skills-pool --skill mean-tweedie-deviance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mean Tweedie Deviance?

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

Security grade badge for Mean Tweedie Deviance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qhjqhj00-mean-tweedie-deviance/badge)](https://www.skillsdirectory.com/skills/qhjqhj00-mean-tweedie-deviance)

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: mean-tweedie-deviance
description: Compute the mean_tweedie_deviance metric — provided by scikit-learn. Use when the user has predictions and ground-truth and needs to compute mean_tweedie_deviance, or asks how to score with mean_tweedie_deviance.
metadata:
  skill_kind: metric
  source_lib: scikit-learn
  import_path: sklearn.metrics.mean_tweedie_deviance
  source: library_introspection
---

# mean-tweedie-deviance

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

## When to invoke this skill

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

## Reference signature

```python
from sklearn.metrics import mean_tweedie_deviance

# mean_tweedie_deviance(y_true, y_pred, *, sample_weight=None, power=0)
```

## Library docstring

```
Mean Tweedie deviance regression loss.

Read more in the :ref:`User Guide <mean_tweedie_deviance>`.

Parameters
----------
y_true : array-like of shape (n_samples,)
    Ground truth (correct) target values.

y_pred : array-like of shape (n_samples,)
    Estimated target values.

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

power : float, default=0
    Tweedie power parameter. Either power <= 0 or power >= 1.

    The higher `p` the less weight is given to extreme
    deviations between true and predicted targets.

    - power < 0: Extreme stable distribution. Requires: y_pred > 0.
    - power = 0 : Normal distribution, output corresponds to
      mean_squared_error. y_true and y_pred can be any real numbers.
    - power = 1 : Poisson distribution. Requires: y_true >= 0 and
      y_pred > 0.
    - 1 < p < 2 : Compound Poisson distribution. Requires: y_true >= 0
      and y_pred > 0.
    - power = 2 : Gamma distribution. Requires: y_true > 0 and y_pred > 0.
    - power = 3 : Inverse Gaussian distribution. Requires: y_true > 0
      and y_pred > 0.
    - otherwise : Positive stable distribution. Requires: y_true > 0
      and y_pred > 0.

Returns
-------
loss : float
    A non-negative floating point value (the best value is 0.0).

Examples
--------
>>> from sklearn.metrics import mean_tweedie_deviance
>>> y_true = [2, 0, 1, 4]
>>> y_pred = [0.5, 0.5, 2., 2.]
>>> mean_tweedie_deviance(y_true, y_pred, power=1)
1.4260...
```

## Quick recipe

```python
import sklearn.metrics as _m
score = _m.mean_tweedie_deviance(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.