reservoirpy.observables.mae#

reservoirpy.observables.mae(
y_true: ndarray,
y_pred: ndarray,
dimensionwise: bool = False,
) float[source]#

Mean absolute error metric:

\[\frac{1}{N} \sum_{i=0}^{N-1} |y_i - \hat{y}_i|\]
Parameters:
  • y_true (array-like of shape (N, features)) – Ground truth values.

  • y_pred (array-like of shape (N, features)) – Predicted values.

  • dimensionwise (boolean, optional) – If True, return a mean absolute error for each dimension of the timeseries.

Returns:

Mean absolute error. If dimensionwise is True, returns a Numpy array of shape $(features, )$.

Return type:

float

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 mae
>>> print(mae(y_true=y_test, y_pred=y_pred))
0.00025325136638810585