intive-DataScience / tbats

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

How can I plot the trend/level/seasonal component using tbats in python? #15

Closed HenryHan960829 closed 4 years ago

HenryHan960829 commented 4 years ago

I can only find fitted_model.forecast to forecast the future, but I can't find the api to plot the trend/level/component using tbats in python. Any clue is appreciated.

cotterpl commented 4 years ago

TBATS is a library holding BATS and TBATS algorithms implementation. It is not a ploting library. I know some libraries provide such functionality but it is not implemented and not planned in TBATS. Feel free to use external time series analysis and plotting tools.

HenryHan960829 commented 4 years ago

TBATS is a library holding BATS and TBATS algorithms implementation. It is not a ploting library. I know some libraries provide such functionality but it is not implemented and not planned in TBATS. Feel free to use external time series analysis and plotting tools.

So, how to get the trend/level/seasonal component of the forecasted data? Any hints will be appreciated.

cotterpl commented 4 years ago

Unfortunately implementation does not reveal or store individual components of series decomposition. You can use parameters of fitted TBATS model to calculate those. Please have a look into examples/detailed_tbats.py where parameter values are being printed out. You can use them to calculate each component according to equations presented at https://medium.com/intive-developers/forecasting-time-series-with-multiple-seasonalities-using-tbats-in-python-398a00ac0e8a

Alternatively you can modify TBATS source code to expose each component. In particular you need to start storing all x vector values in tbats.abstract.Model.Model._fit_to_observations. In order to discover what type of component is 'hidden' behind each x dimension please refer to build.lib.tbats.abstract.ModelParams.ModelParams.to_vector

HenryHan960829 commented 4 years ago

Unfortunately implementation does not reveal or store individual components of series decomposition. You can use parameters of fitted TBATS model to calculate those. Please have a look into examples/detailed_tbats.py where parameter values are being printed out. You can use them to calculate each component according to equations presented at https://medium.com/intive-developers/forecasting-time-series-with-multiple-seasonalities-using-tbats-in-python-398a00ac0e8a

Alternatively you can modify TBATS source code to expose each component. In particular you need to start storing all x vector values in tbats.abstract.Model.Model._fit_to_observations. In order to discover what type of component is 'hidden' behind each x dimension please refer to build.lib.tbats.abstract.ModelParams.ModelParams.to_vector

Ok, thank you very well.