You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why is it so hard to get residuals, right after fitting the model? I want to see the in-sample residuals, but I need to use the method residuals, which takes time to compute.
The text was updated successfully, but these errors were encountered:
Hi @franc703, we want to provide a unified API, so that all models have the same support.
Not all models support the in-sample residuals out of the box (e.g. torch models, regression models). Therefore we offer the residuals() method to compute them with any model.
If you know that your specific models supports it, you can always access the model with ForecastingModel.model after training.
Our residuals() method offers much more support than the fitted values (residuals on a historic simulation of re-applying the model, multi-horizon residuals, ...).
With global pre-trained models, computing the residuals is quite fast, since we use optimized routines to generate the historical forecasts.
We recently updated the documentation of residuals(), which should explain what's happening behind the hood (and why we can't just return fitted values).
"""Compute the residuals that the model produced for historical forecasts on (potentially multiple) `series`.
This function computes the difference (or one of Darts' "per time step" metrics) between the actual
observations from `series` and the fitted values obtained by training the model on `series` (or using a
pre-trained model with `retrain=False`). Not all models support fitted values, so we use historical forecasts
as an approximation for them.
In sequence this method performs:
- use pre-computed `historical_forecasts` or compute historical forecasts for each series (see
:meth:`~darts.models.forecasting.forecasting_model.ForecastingModel.historical_forecasts` for more details).
How the historical forecasts are generated can be configured with parameters `num_samples`, `train_length`,
`start`, `start_format`, `forecast_horizon`, `stride`, `retrain`, `last_points_only`, `fit_kwargs`, and
`predict_kwargs`.
- compute a backtest using a "per time step" `metric` between the historical forecasts and `series` per
component/column and time step (see
:meth:`~darts.models.forecasting.forecasting_model.ForecastingModel.backtest` for more details). By default,
uses the residuals :func:`~darts.metrics.metrics.err` (error) as a `metric`.
- create and return `TimeSeries` (or simply a np.ndarray with `values_only=True`) with the time index from
historical forecasts, and values from the metrics per component and time step.
This method works for single or multiple univariate or multivariate series.
It uses the median prediction (when dealing with stochastic forecasts).
"""
Why is it so hard to get residuals, right after fitting the model? I want to see the in-sample residuals, but I need to use the method residuals, which takes time to compute.
The text was updated successfully, but these errors were encountered: