reservoirpy.observables.nrmse#
- reservoirpy.observables.nrmse(
- y_true: ndarray,
- y_pred: ndarray,
- norm: Literal['minmax', 'var', 'mean', 'q1q3'] = 'minmax',
- norm_value: float | None = None,
- dimensionwise: bool = False,
Normalized root mean squared error metric:
\[\frac{1}{\lambda} * \sqrt{\frac{\sum_{i=0}^{N-1} (y_i - \hat{y}_i)^2}{N}}\]- where \(\lambda\) may be:
\(\max y - \min y\) (Peak-to-peak amplitude) if
norm="minmax";\(\mathrm{Var}(y)\) (variance over time) if
norm="var";\(\mathbb{E}[y]\) (mean over time) if
norm="mean";\(Q_{3}(y) - Q_{1}(y)\) (quartiles) if
norm="q1q3";or any value passed to
norm_value.
- Parameters:
y_true (array-like of shape (N, features)) – Ground truth values.
y_pred (array-like of shape (N, features)) – Predicted values.
norm ({"minmax", "var", "mean", "q1q3"}, default to "minmax") – Normalization method.
norm_value (float, optional) – A normalization factor. If set, will override the
normparameter.dimensionwise (boolean, optional) – If True, return a mean squared error for each dimension of the timeseries
- Returns:
float – Normalized root mean squared error.
If dimensionwise is True, returns a Numpy array of shape $(features, )$.
- Return type:
Examples
>>> from reservoirpy.nodes import Reservoir, Ridge >>> model = Reservoir(units=100, sr=1) >> Ridge(ridge=1e-8)
>>> from reservoirpy.datasets import mackey_glass, to_forecasting >>> x_train, x_test, y_train, y_test = to_forecasting(mackey_glass(1000), test_size=0.2) >>> y_pred = model.fit(x_train, y_train).run(x_test)
>>> from reservoirpy.observables import nrmse >>> print(nrmse(y_true=y_test, y_pred=y_pred, norm="var")) 0.007854318015438394