Repository: sktime/sktime

Issue:
[ENH] Implement update method for TBATS
**Is your feature request related to a problem? Please describe.**
Want to perform walk-forward predictions using TBATS model. without refitting parameters every time. This is crucial for validation, especially since TBATS model is slow to train. 

**Describe the solution you'd like**
Implement update method for TBATS... same as interface used for other time series forecasters in sktime.



Discussion:
Hm, I think the `tbats` package that we interface does not have an updating capability, therefore the `sktime` `update` defaults to refitting.
I've opened an issue on `tbats` here: https://github.com/intive-DataScience/tbats/issues/35

If you want to control how often you refit, you can use the wrappers in the `forecasting.stream` module that will be added with 0.13.1 (you can try them out on the dev version), feedback appreciated. Note that this will still refit, but you can say sth like "I want to refit only every month".


Thank you @fkiraly. I definitely have what I need now to use this functionality! Might be worth implementing a similar ‘update’ wrapper method to that used for other sktime models. Especially given the ‘refit_model.py’ logic is short and self-contained. Let me know if you’d like me to create a PR for this? Regardless really appreciate the follow up.
>Especially given the ‘refit_model.py’ logic is short and self-contained.

Which `refit_model.py` are you referring to?

> Let me know if you’d like me to create a PR for this? Regardless really appreciate the follow up.

Sure, would be appreciated! What precisely would you like to implement?
Oh, in the TBATS repository, I get it.

Yes, would appreciate a PR! If you need access to the pooled data, the `self._y` attribute stores the updated `y`.
Perfect, can do. I tried creating a branch with my update and pushing it to the repo (from which I’d create a PR for your review) but it looks like I’d need to be granted some access permissions. Can you help or do I need to do a bunch of required onboarding?

Sent from my iPhone 

> Le 21 juil. 2022 à 9:28 PM, Franz Király ***@***.***> a écrit :
> 
> ﻿
> Oh, in the TBATS repository, I get it.
> 
> Yes, would appreciate a PR! If you need access to the pooled data, the self._y attribute stores the updated y.
> 
> —
> Reply to this email directly, view it on GitHub, or unsubscribe.
> You are receiving this because you authored the thread.

>Perfect, can do. I tried creating a branch with my update and pushing it to the repo (from which I’d create a PR for your review) but it looks like I’d need to be granted some access permissions. Can you help or do I need to do a bunch of required onboarding?

Only core devs can push directly to this repo, you need to fork and make a PR from your fork.
(this is the typical open source contribution workflow, so once you've seen it you know it)
Instructions here: https://www.sktime.org/en/stable/developer_guide/git_workflow.html
need any help, @jelc53?
Thanks @fkiraly, makes sense. This is my first time contributing to a public repo. Ill have a read through the link and give it a go later today!

Resolving patch:
diff --git a/sktime/forecasting/base/adapters/_tbats.py b/sktime/forecasting/base/adapters/_tbats.py
--- a/sktime/forecasting/base/adapters/_tbats.py
+++ b/sktime/forecasting/base/adapters/_tbats.py
@@ -103,7 +103,38 @@ def _fit(self, y, X=None, fh=None):
 
         return self
 
-    def _predict(self, fh, X):
+    def _update(self, y, X=None, update_params=True):
+        """Update time series to incremental training data.
+
+        Derived from example provided by core devs in TBATS repository
+        https://github.com/intive-DataScience/tbats/blob/master/examples/
+
+        Parameters
+        ----------
+        y : pd.Series
+            Target time series to which to fit the forecaster.
+        X : pd.DataFrame, optional (default=None)
+            Exogenous variables (ignored)
+        update_params : bool, optional (default=True)
+            whether model parameters should be updated
+
+        Returns
+        -------
+        self : reference to self
+        """
+        if update_params:
+            # update model state and refit parameters
+            # _fit re-runs model instantiation which triggers refit
+            self._fit(y=self._y)
+
+        else:
+            # update model state without refitting parameters
+            # out-of-box fit tbats method will not refit parameters
+            self._forecaster.fit(y=self._y)
+
+        return self
+
+    def _predict(self, fh, X=None):
         """Forecast time series at future horizon.
 
         Parameters


Test patch: