Skip to content

Commit

Permalink
Merge branch 'master' into feature/rnn-normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
JanFidor committed May 15, 2023
2 parents e89c22e + 83e9171 commit 544ab44
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
9 changes: 7 additions & 2 deletions darts/models/forecasting/arima.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
q: int = 0,
seasonal_order: Tuple[int, int, int, int] = (0, 0, 0, 0),
trend: Optional[str] = None,
random_state: int = 0,
random_state: Optional[int] = None,
add_encoders: Optional[dict] = None,
):
"""ARIMA
Expand Down Expand Up @@ -81,7 +81,11 @@ def __init__(
self.seasonal_order = seasonal_order
self.trend = trend
self.model = None
np.random.seed(random_state)
self._random_state = (
random_state
if random_state is None
else np.random.RandomState(random_state)
)

def _fit(self, series: TimeSeries, future_covariates: Optional[TimeSeries] = None):
super()._fit(series, future_covariates)
Expand Down Expand Up @@ -144,6 +148,7 @@ def _predict(
nsimulations=n,
repetitions=num_samples,
initial_state=self.model.states.predicted[-1, :],
random_state=self._random_state,
exog=future_covariates.values(copy=False)
if future_covariates
else None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def test_model_repr_call(self):
), # no params changed
(
ARIMA(1, 1, 1),
"ARIMA(p=1, d=1, q=1, seasonal_order=(0, 0, 0, 0), trend=None, random_state=0, add_encoders=None)",
"ARIMA(p=1, d=1, q=1, seasonal_order=(0, 0, 0, 0), trend=None, random_state=None, add_encoders=None)",
), # default value for a param
]
for model, expected in model_expected_name_pairs:
Expand Down
3 changes: 1 addition & 2 deletions darts/tests/models/forecasting/test_probabilistic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

models_cls_kwargs_errs = [
(ExponentialSmoothing, {}, 0.3),
(ARIMA, {"p": 1, "d": 0, "q": 1}, 0.03),
(ARIMA, {"p": 1, "d": 0, "q": 1, "random_state": 42}, 0.03),
]

models_cls_kwargs_errs += [
Expand Down Expand Up @@ -150,7 +150,6 @@ class ProbabilisticTorchModelsTestCase(DartsBaseTestClass):
def test_fit_predict_determinism(self):

for model_cls, model_kwargs, _ in models_cls_kwargs_errs:

# whether the first predictions of two models initiated with the same random state are the same
model = model_cls(**model_kwargs)
model.fit(self.constant_noisy_ts)
Expand Down
2 changes: 1 addition & 1 deletion requirements/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ joblib>=0.16.0
lightgbm>=3.2.0
matplotlib>=3.3.0
nfoursid>=1.0.0
numpy>=1.19.0
numpy>=1.19.0,<1.24.0
pandas>=1.0.5
pmdarima>=1.8.0
prophet>=1.1.1
Expand Down

0 comments on commit 544ab44

Please sign in to comment.