Skip to content

Commit

Permalink
fix: indexing and seasonal_periods check that endog is at least twice…
Browse files Browse the repository at this point in the history
… the size (#1305)
  • Loading branch information
Lopa10ko authored Jun 14, 2024
1 parent ec12d26 commit 0f22840
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def predict(self, input_data):
predictions = self.model.forecast(steps=forecast_length)
predict = np.array(predictions).reshape(1, -1)

input_data.idx = np.arange(start_id, end_id)
input_data.idx = np.arange(start_id, end_id + 1)

output_data = self._convert_to_output(input_data,
predict=predict,
Expand Down Expand Up @@ -345,4 +345,10 @@ def _check_and_correct_params(self, endog: np.ndarray) -> bool:
self.params.update(**{'trend': 'add'})
params_changed = True

if self.params.get('seasonal'):
self.seasonal_periods = min(int(0.5 * (len(endog) - 1)), self.seasonal_periods)
self.seasonal_periods = max(self.seasonal_periods, 1)
self.params.update(**{'seasonal_periods': self.seasonal_periods})
params_changed = True

return params_changed

0 comments on commit 0f22840

Please sign in to comment.