intive-DataScience / tbats

BATS and TBATS forecasting methods
MIT License
178 stars 19 forks source link

Ability to retrieve params and instantiate new model from these params #19

Open maxupp opened 4 years ago

maxupp commented 4 years ago

I'm looking for the ability to extract the parameters from the fit tbats estimator.

I would then like to recreate this model and fit it directly without evaluating all the other candidates. The background is that I am building a forecasting server where model selection should only be done once, and every time after that, the user provides the parameters that he was originally served.

cotterpl commented 4 years ago

Current implementation does not provide this out of the box. One needs to implement that functionality.

cotterpl commented 4 years ago

I have analyzed your message once more and I am not sure what you are trying to achieve. There are two layers of fitting: Level 1: choosing whether to use trend/dumping/arma/boxcox ... (for example trend=True, arma=False) Level 2: finding optimal values for parameters for case(s) from level 1 (for example alpha=0.9, p=1)

If you only need the level 1 then have a look at examples/detailed_tbats.py, lines displaying components.* values. You can use those directly to construct particular case of TBATS (after level 1 optimization).

Is this what you need?

maxupp commented 4 years ago

Yes that's part of what I want to do. Optimally I would also like to have level 2.

xinnyuann commented 2 years ago

Thanks for bringing up this discussion :) I have a similar use case, where I let tbats do level 1 & level 2 jobs and saved the fitted_model, then I re-used the fitted_model when new data came in - according to https://github.com/intive-DataScience/tbats/blob/master/examples/re_fit_model.py , and the comments " # Re-calculate model for new observation, it will not change model parameters", my understand is, re-fitting the model with new observations will calculate y_hat for each of the new data point and make steps of forecast, but it will not redo level 1 and level 2. So the model config and parameters will stay the same as fitted_model, is my understanding correct?

cotterpl commented 2 years ago

Yes. It will keep parameters the same. It only recalculates model state to be able to predict for next days after new observations.