Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StatsForecastETS now is probabilistic in the same way as StatsForecas… #1

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions darts/models/forecasting/sf_ets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from typing import Optional

import numpy as np
from statsforecast.models import ETS

from darts import TimeSeries
Expand Down Expand Up @@ -97,9 +98,18 @@ def _predict(
forecast_df = self.model.predict(
h=n,
X=future_covariates.values(copy=False) if future_covariates else None,
level=(68.27,), # ask one std for the confidence interval
)

return self._build_forecast_series(forecast_df["mean"])
mu = forecast_df["mean"]
if num_samples > 1:
std = forecast_df["hi-68.27"] - mu
samples = np.random.normal(loc=mu, scale=std, size=(num_samples, n)).T
samples = np.expand_dims(samples, axis=1)
else:
samples = mu

return self._build_forecast_series(samples)

@property
def min_train_series_length(self) -> int:
Expand All @@ -109,4 +119,4 @@ def _supports_range_index(self) -> bool:
return True

def _is_probabilistic(self) -> bool:
return False
return True