# Normalizedrootmeansquarederror

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

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

---


# normalizedrootmeansquarederror

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

## When to invoke this skill

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

## Reference signature

```python
from torchmetrics import NormalizedRootMeanSquaredError

# NormalizedRootMeanSquaredError(normalization: Literal['mean', 'range', 'std', 'l2'] = 'mean', num_outputs: int = 1, **kwargs: Any) -> None
```

## Library docstring

```
Calculates the `Normalized Root Mean Squared Error`_ (NRMSE) also know as scatter index.

The metric is defined as:

.. math::
    \text{NRMSE} = \frac{\text{RMSE}}{\text{denom}}

where RMSE is the root mean squared error and `denom` is the normalization factor. The normalization factor can be
either be the mean, range, standard deviation or L2 norm of the target, which can be set using the `normalization`
argument.

As input to ``forward`` and ``update`` the metric accepts the following input:

- ``preds`` (:class:`~torch.Tensor`): Predictions from model
- ``target`` (:class:`~torch.Tensor`): Ground truth values

As output of ``forward`` and ``compute`` the metric returns the following output:

- ``nrmse`` (:class:`~torch.Tensor`): A tensor with the mean squared error

Args:
    normalization: type of normalization to be applied. Choose from "mean", "range", "std", "l2" which corresponds
      to normalizing the RMSE by the mean of the target, the range of the target, the standard deviation of the
      target or the L2 norm of the target.
    num_outputs: Number of outputs in multioutput setting
    kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.

Example::
    Single output normalized root mean squared error computation:

    >>> import torch
    >>> from torchmetrics import NormalizedRootMeanSquaredError
    >>> target = torch.tensor([2.5, 5.0, 4.0, 8.0])
    >>> preds = torch.tensor([3.0, 5.0, 2.5, 7.0])
    >>> nrmse = NormalizedRootMeanSquaredError(normalization="mean")
    >>> nrmse(preds, target)
    tensor(0.1919)
    >>> nrmse = NormalizedRootMeanSquaredError(normalization="range")
    >>> nrmse(preds, target)
    tensor(0.1701)

Example::
    Multioutput normalized root mean squared error computation:

    >>> import torch
    >>> from torchmetrics import NormalizedRootMeanSquaredError
    >>> preds = torch.tensor([[0., 1], [2, 3], [4, 5], [6, 7]])
    >>> target = torch.tensor([[0., 1], [3, 3], [4, 5], [8, 9]])
    >>> nrmse = NormalizedRootMeanSquaredError(num_outputs=2)
    >>> nrmse(preds, target)
    tensor([0.2981, 0.2222])
```

## Quick recipe

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

