---
title: Normalized Root Mean Squared Error (NRMSE)
description: >-
  Calculates the Normalized Root Mean Squared Error (NRMSE) also know as scatter
  index.
canonical: >-
  https://lightning.ai/docs/torchmetrics/stable/regression/normalized_root_mean_squared_error
---
# Normalized Root Mean Squared Error (NRMSE) {#normalized-root-mean-squared-error-nrmse}

## Module Interface {#module-interface}

### `class torchmetrics.NormalizedRootMeanSquaredError(normalization='mean', num_outputs=1, **kwargs)` {#torchmetrics.NormalizedRootMeanSquaredError}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/regression/nrmse.py#L95-L280)

Calculates the [Normalized Root Mean Squared Error](https://onlinelibrary.wiley.com/doi/abs/10.1111/1365-2478.12109) (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` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): Predictions from model
    
*   `target` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): Ground truth values
    

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

*   `nrmse` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): A tensor with the mean squared error
    

Parameters:

*   **normalization** ([`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'mean'`, `'range'`, `'std'`, `'l2'`\]) – 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** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – Number of outputs in multioutput setting
    
*   **kwargs** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")) – Additional keyword arguments, see [Advanced metric settings](/docs/torchmetrics/1.9.0/user-guide/overview.md#metric-kwargs) for more info.
    

Example::

Single output normalized root mean squared error computation:

```python
>>> 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:

```python
>>> 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])
```

#### `plot(val=None, ax=None)` {#torchmetrics.NormalizedRootMeanSquaredError.plot}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/regression/nrmse.py#L240-L280)

Plot a single or multiple values from the metric.

Parameters:

*   **val** (`Union`\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)"), [`Sequence`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.15)")\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")\], [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – Either a single result from calling metric.forward or metric.compute or a list of these results. If no value is provided, will automatically call metric.compute and plot that result.
    
*   **ax** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Axes`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes "(in Matplotlib v3.11.2)")\]) – An matplotlib axis object. If provided will add plot to that axis
    

Return type:

[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple "(in Python v3.15)")\[[`Figure`](https://matplotlib.org/stable/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure "(in Matplotlib v3.11.2)"), `Union`\[[`Axes`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes "(in Matplotlib v3.11.2)"), [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.5)")\]\]

Returns:

Figure and Axes object

Raises:

[**ModuleNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#ModuleNotFoundError "(in Python v3.15)") – If matplotlib is not installed

```python
>>> from torch import randn
>>> # Example plotting a single value
>>> from torchmetrics.regression import NormalizedRootMeanSquaredError
>>> metric = NormalizedRootMeanSquaredError()
>>> metric.update(randn(10,), randn(10,))
>>> fig_, ax_ = metric.plot()
```

[![../../\_images/normalized\_root\_mean\_squared\_error-1.png](/docs/torchmetrics/1.9.0/static/_images/normalized_root_mean_squared_error-1.png)](/docs/torchmetrics/1.9.0/static/_images/normalized_root_mean_squared_error-1.png)

```python
>>> from torch import randn
>>> # Example plotting multiple values
>>> from torchmetrics.regression import NormalizedRootMeanSquaredError
>>> metric = NormalizedRootMeanSquaredError()
>>> values = []
>>> for _ in range(10):
...     values.append(metric(randn(10,), randn(10,)))
>>> fig, ax = metric.plot(values)
```

[![../../\_images/normalized\_root\_mean\_squared\_error-2.png](/docs/torchmetrics/1.9.0/static/_images/normalized_root_mean_squared_error-2.png)](/docs/torchmetrics/1.9.0/static/_images/normalized_root_mean_squared_error-2.png)

## Functional Interface {#functional-interface}

### `torchmetrics.functional.normalized_root_mean_squared_error(preds, target, normalization='mean', num_outputs=1)` {#torchmetrics.functional.normalized_root_mean_squared_error}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/functional/regression/nrmse.py#L61-L106)

Calculates the [Normalized Root Mean Squared Error](https://onlinelibrary.wiley.com/doi/abs/10.1111/1365-2478.12109) (NRMSE) also know as scatter index.

Parameters:

*   **preds** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – estimated labels
    
*   **target** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – ground truth labels
    
*   **normalization** ([`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'mean'`, `'range'`, `'std'`, `'l2'`\]) – 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** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – Number of outputs in multioutput setting
    

Return type:

[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")

Returns:

Tensor with the NRMSE score

Example

```python
>>> import torch
>>> from torchmetrics.functional.regression import normalized_root_mean_squared_error
>>> preds = torch.tensor([0., 1, 2, 3])
>>> target = torch.tensor([0., 1, 2, 2])
>>> normalized_root_mean_squared_error(preds, target, normalization="mean")
tensor(0.4000)
>>> normalized_root_mean_squared_error(preds, target, normalization="range")
tensor(0.2500)
>>> normalized_root_mean_squared_error(preds, target, normalization="std")
tensor(0.6030)
>>> normalized_root_mean_squared_error(preds, target, normalization="l2")
tensor(0.1667)
```

Example (multioutput):

```python
>>> import torch
>>> from torchmetrics.functional.regression import normalized_root_mean_squared_error
>>> preds = torch.tensor([[0., 1], [2, 3], [4, 5], [6, 7]])
>>> target = torch.tensor([[0., 1], [3, 3], [4, 5], [8, 9]])
>>> normalized_root_mean_squared_error(preds, target, normalization="mean", num_outputs=2)
tensor([0.2981, 0.2222])
```

---

**Navigation**

- Parent: [Regression](/docs/torchmetrics/1.9.0/regression.md)
