Skip to content

feat: add forward() method to AutoMFLES and AutoTBATS#1094

Open
W057 wants to merge 2 commits intoNixtla:mainfrom
W057:fix/issue-911-automfles-forward
Open

feat: add forward() method to AutoMFLES and AutoTBATS#1094
W057 wants to merge 2 commits intoNixtla:mainfrom
W057:fix/issue-911-automfles-forward

Conversation

@W057
Copy link

@W057 W057 commented Feb 15, 2026

Summary

  • Adds forward() method to AutoMFLES and AutoTBATS, enabling cross_validation(refit=False) and integer refit values
  • Both methods follow the same signature as other Auto* models (AutoARIMA, AutoETS, AutoCES, AutoTheta)
  • The implementation delegates to forecast() which re-fits the model on the new time series

Changes

python/statsforecast/models.py

  • Added AutoMFLES.forward() after forecast()
  • Added AutoTBATS.forward() after forecast()

Test plan

  • AutoMFLES with cross_validation(refit=False) works (multi-series, 3 series x 2 windows x h=12 = 72 rows)
  • AutoMFLES with cross_validation(refit=2) works (integer refit, 108 rows)
  • AutoMFLES with cross_validation(refit=True) still works (regression check)
  • AutoTBATS with cross_validation(refit=False) works
  • AutoTBATS with cross_validation(refit=2) works
  • forward() directly returns valid mean and fitted values (no NaN)
  • Both methods raise exception if called before fit()

Closes #911

Enables cross_validation(refit=False) and integer refit for these models.
The forward() method delegates to forecast() which re-fits the model
on the new time series, matching the expected signature and behavior.

Closes Nixtla#911
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72108f65ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"""
if not hasattr(self, "model_"):
raise Exception("You have to use the `fit` method first")
return self.forecast(y=y, h=h, X=X, X_future=X_future, level=level, fitted=fitted)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reuse fitted model in AutoMFLES.forward

forward currently returns self.forecast(...), but forecast calls self._fit(...) internally, so every forward invocation re-runs AutoMFLES selection instead of applying the model fitted in fit(). In cross_validation with refit=False or integer refit (documented in core.py as fit-once/periodic-refit behavior), this effectively keeps refitting on every window and can even double-fit on windows where should_fit is true, causing unexpected runtime and semantics.

Useful? React with 👍 / 👎.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an important issue

"""
if not hasattr(self, "model_"):
raise Exception("You have to use the `fit` method first")
return self.forecast(y=y, h=h, X=X, X_future=X_future, level=level, fitted=fitted)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reuse fitted model in AutoTBATS.forward

forward delegates to self.forecast(...), and forecast rebuilds the model via tbats_selection(...) each call, so the fitted self.model_ is never used for forward updates. This breaks the intended cross_validation(refit=False/int) behavior by refitting every window anyway (and doing an extra fit on scheduled refit windows), which can significantly increase compute and makes refit frequency ineffective.

Useful? React with 👍 / 👎.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this too.

…BATS

AutoMFLES: store optim_params and seasonal_period from optimize(),
reuse them in forward() via _MFLES.fit() directly.

AutoTBATS: use model_["description"] to fix structural choices
(boxcox, trend, damping, arma) so tbats_selection() only fits
one combination instead of searching all.

Closes Nixtla#911
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto MFLES - add forward method

2 participants

Comments