forecaster.metrics.root_mean_squared_scaled_error
forecaster.metrics.root_mean_squared_scaled_error(y_true, y_pred, y_train)Root Mean Squared Scaled Error (RMSSE).
RMSSE is a scale-independent error metric that measures the accuracy of a forecast. It is the root mean squared error of the forecast divided by the root mean squared 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 | RMSSE value. |
Examples
>>> from spotforecast2.forecaster.metrics import root_mean_squared_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])
>>> rmsse = root_mean_squared_scaled_error(y_true, y_pred, y_train)
>>> rmsse < 1.0 # Good forecast
True