# Max Error

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

- Skill: `qhjqhj00/max-error` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/max-error`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/max-error/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/max-error

---


# max-error

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

## When to invoke this skill

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

## Reference signature

```python
from sklearn.metrics import max_error

# max_error(y_true, y_pred)
```

## Library docstring

```
The max_error metric calculates the maximum residual error.

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

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.

Returns
-------
max_error : float
    A positive floating point value (the best value is 0.0).

Examples
--------
>>> from sklearn.metrics import max_error
>>> y_true = [3, 2, 7, 1]
>>> y_pred = [4, 2, 7, 1]
>>> max_error(y_true, y_pred)
1.0
```

## Quick recipe

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

