Extracting component data-frames
Hello!
Is there a way to extract the data-frames responsible for the trend, seasonality, and holiday components? I am asking because I'd like to visualize these components separately using another tool.
Thank you
Hi! For trend and holidays, it should just be the trend and holidays columns in the forecast dataframe. i.e. if you ran forecast = m.predict(future), the data will be in the columns of the forecast dataframe.
For the seasonal components, you'll have to extract some of the source code into your own function. For example, here is the weekly seasonality plotting logic:
- Python: https://github.com/facebook/prophet/blob/b75844e07c3b09bf3bc383c9d43241c554dd251b/python/prophet/plot.py#L273-L301
- R: https://github.com/facebook/prophet/blob/b75844e07c3b09bf3bc383c9d43241c554dd251b/R/R/plot.R#L247-L268
If you return the seas variable from each of those functions, you'll get the dataframe required for plotting.
Thank you! That's exactly what I was looking for:)
Hi @tcuongd , Regarding trend or seasonality, source code focuses on plotting components of forecast data frame. Yet in the guide of Quick Start, plot_component or add_changepoints_to_plot not only shows trend for forecast part, but also shows trend for historical data part. Is there a way to extract fitted value or components of training data set?
Thanks a lot!