Skip to content

Commit

Permalink
multiple TimeSeries for historical_forecasts(), residuals() and backt…
Browse files Browse the repository at this point in the history
…est() + automatic start (#1318)

* init

* improvements

* corrections

* improvements

* unit tests improv || uses/supports/expected covariates clarifications

* cleaning

* adjustments

* utils slice time index changes

* corrections

* correction

* correction

* Update darts/models/forecasting/forecasting_model.py

Co-authored-by: Julien Herzen <julien@unit8.co>

* Update darts/models/forecasting/forecasting_model.py

Co-authored-by: Julien Herzen <julien@unit8.co>

* Update darts/models/forecasting/forecasting_model.py

Co-authored-by: Julien Herzen <julien@unit8.co>

* Update darts/models/forecasting/forecasting_model.py

Co-authored-by: Julien Herzen <julien@unit8.co>

* Update darts/models/forecasting/forecasting_model.py

Co-authored-by: Julien Herzen <julien@unit8.co>

* Update darts/tests/models/forecasting/test_historical_forecasts.py

Co-authored-by: Julien Herzen <julien@unit8.co>

* Update darts/models/forecasting/forecasting_model.py

* Some PR comments

* Remove uses_X_covs from doc blacklist

* Fix a test in metrics

Co-authored-by: Julien Herzen <julien@unit8.co>
  • Loading branch information
dumjax and hrzn authored Dec 20, 2022
1 parent 0d924c8 commit d315dd8
Show file tree
Hide file tree
Showing 13 changed files with 1,553 additions and 261 deletions.
8 changes: 4 additions & 4 deletions darts/explainability/explainability.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ def __init__(
self.background_past_covariates = series2seq(background_past_covariates)
self.background_future_covariates = series2seq(background_future_covariates)

if self.model.uses_past_covariates:
if self.model.supports_past_covariates:
raise_if(
self.model._expect_past_covariates
self.model.uses_past_covariates
and self.background_past_covariates is None,
"A background past covariates is not provided, but the model needs past covariates.",
)

if self.model.uses_future_covariates:
if self.model.supports_future_covariates:
raise_if(
self.model._expect_future_covariates
self.model.uses_future_covariates
and self.background_future_covariates is None,
"A background future covariates is not provided, but the model needs future covariates.",
)
Expand Down
8 changes: 6 additions & 2 deletions darts/models/forecasting/baselines.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def predict(self, n: int, num_samples: int = 1, verbose: bool = False):
forecast = np.array([self.last_k_vals[i % self.K, :] for i in range(n)])
return self._build_forecast_series(forecast)

@property
def extreme_lags(self):
return (-self.K, 1, None, None, None)


class NaiveDrift(LocalForecastingModel):
def __init__(self):
Expand Down Expand Up @@ -145,9 +149,9 @@ def fit(
for model in self.models:
if self.is_global_ensemble:
kwargs = dict(series=series)
if model.uses_past_covariates:
if model.supports_past_covariates:
kwargs["past_covariates"] = past_covariates
if model.uses_future_covariates:
if model.supports_future_covariates:
kwargs["future_covariates"] = future_covariates
model.fit(**kwargs)
else:
Expand Down
Loading

0 comments on commit d315dd8

Please sign in to comment.