forecaster.metrics.mean_absolute_scaled_error
forecaster.metrics.mean_absolute_scaled_error(y_true, y_pred, y_train)Mean Absolute Scaled Error (MASE).
MASE is a scale-independent error metric that measures the accuracy of a forecast. It is the mean absolute error of the forecast divided by the mean absolute error of a naive forecast in the training set. The naive forecast is the one obtained by shifting the time series by one period. If y_train is a list of numpy arrays or pandas Series, it is considered that each element is the true value of the target variable in the training set for each time series. In this case, the naive forecast is calculated for each time series separately.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| y_true | np.ndarray | pd.Series | True values of the target variable. | required |
| y_pred | np.ndarray | pd.Series | Predicted values of the target variable. | required |
| y_train | list[float] | np.ndarray | pd.Series | True values of the target variable in the training set. If list, it is consider that each element is the true value of the target variable in the training set for each time series. |
required |
Returns
| Name | Type | Description |
|---|---|---|
| float | MASE value. |
Examples
>>> from spotforecast2.forecaster.metrics import mean_absolute_scaled_error
>>> y_train = np.array([1, 2, 3, 4, 5, 6, 7, 8])
>>> y_true = np.array([9, 10, 11])
>>> y_pred = np.array([8.8, 10.2, 10.9])
>>> mase = mean_absolute_scaled_error(y_true, y_pred, y_train)
>>> mase < 1.0 # Good forecast
True