facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.34k stars 4.52k forks source link

R: add layer of future actuals to output of dyplot.prophet() #695

Closed henningsway closed 5 years ago

henningsway commented 6 years ago

I am considering using dyplot.prophet to communicate the results of some uplift-modeling.

For this I need to contrast the predictions with the actuals (after they have occurred). With the ggplot-output I can just add another layer (with new data) to the plot.

Dygraphs seems to require all the data in the initial dataframe, but the prophet forecast doesn't contain any actuals in the forecast period.

Do you see a way to use/extend the provided dyplot.prophet functionality?

bletham commented 5 years ago

I'm not familiar enough with dygraphs to know of a way to add data to the plot after it has been generated, but the code to generate the plot is actually fairly simple. It is right here: https://github.com/facebook/prophet/blob/master/R/R/plot.R#L391

I would just copy that code out and then edit it to add in whatever you'd like. The only thing to be aware of is the call here to df_for_plotting: https://github.com/facebook/prophet/blob/master/R/R/plot.R#L397 . This function is not exported so to use it in your own code you'll have to do prophet:::df_for_plotting().

henningsway commented 5 years ago

Thank you!