# Minmaxmetric

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

- Skill: `qhjqhj00/minmaxmetric` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/minmaxmetric`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/minmaxmetric/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/minmaxmetric

---


# minmaxmetric

> Metric `MinMaxMetric` from `torchmetrics` (torchmetrics.MinMaxMetric)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with MinMaxMetric, or
mentions `torchmetrics.MinMaxMetric` directly, or wants the standard torchmetrics implementation.

## Reference signature

```python
from torchmetrics import MinMaxMetric

# MinMaxMetric(base_metric: torchmetrics.metric.Metric, **kwargs: Any) -> None
```

## Library docstring

```
Wrapper metric that tracks both the minimum and maximum of a scalar/tensor across an experiment.

The min/max value will be updated each time ``.compute`` is called.

Args:
    base_metric:
        The metric of which you want to keep track of its maximum and minimum values.
    kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.

Raises:
    ValueError
        If ``base_metric` argument is not a subclasses instance of ``torchmetrics.Metric``

Example::
    >>> import torch
    >>> from torchmetrics.wrappers import MinMaxMetric
    >>> from torchmetrics.classification import BinaryAccuracy
    >>> from pprint import pprint
    >>> base_metric = BinaryAccuracy()
    >>> minmax_metric = MinMaxMetric(base_metric)
    >>> preds_1 = torch.Tensor([[0.1, 0.9], [0.2, 0.8]])
    >>> preds_2 = torch.Tensor([[0.9, 0.1], [0.2, 0.8]])
    >>> labels = torch.Tensor([[0, 1], [0, 1]]).long()
    >>> pprint(minmax_metric(preds_1, labels))
    {'max': tensor(1.), 'min': tensor(1.), 'raw': tensor(1.)}
    >>> pprint(minmax_metric.compute())
    {'max': tensor(1.), 'min': tensor(1.), 'raw': tensor(1.)}
    >>> minmax_metric.update(preds_2, labels)
    >>> pprint(minmax_metric.compute())
    {'max': tensor(1.), 'min': tensor(0.7500), 'raw': tensor(0.7500)}
```

## Quick recipe

```python
import torchmetrics as _m
score = _m.MinMaxMetric(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)`.

