Goal-Based Forecasting in Prophet & R

One way to check is to look at weekdays vs.

weekends:????‍♀ Weekdays vs.

Weekends ????In 2017, weekends saw lower ridership than weekdays, but that trend changed by 2018 to be more or less equal.

This is the sort of thing that Prophet handles well by decomposing for overall trend and by daily, weekly, and yearly seasonality, out-of-the-box.

I called prophet() on the historical data to generate the Prophet model, then called predict() which uses that Prophet model to forecast daily rides out to September 1, 2019.

For this example, I made the trend less flexible by decreasing the changepoint parameter from the default of 0.

05 to 0.

01:According to this model, we’ll have 1,272 rides on September 1, 2019This Prophet model generated forecasts for each day between September 29, 2018 and September 1, 2019, and predicted 1,272 rides on September 1, 2019.

To see how Prophet decomposes trend and seasonality, prophet_plot_components() generates the following chart:????.????.Components of a Prophet model.

A very linear trend across years, lower ridership on weekends, and higher ridership during late summer — all that goes into the model and are weighted towards calculating the daily ridership projections.

Goal: 1,500 ridesBut the sales team wants to reach 1,500 rides by September 1, 2019.

With that target in mind, what should our daily ridership look like?Running predictive_samples() using the same Prophet model returned 1,000 samples (as columns) from the posterior predictive distribution, with as many rows as there are for days you predicted over.

As explained above, each one of them is a possible, plausible forecast.

I looked at the row corresponding to September 1, 2019 then found the cell closest to 1,500 rides across the 1,000 columns (samples).

The column containing that cell is the adjusted, goal-based forecast I want to give to the sales team!The red dots below show the adjusted daily ridership we want to achieve in order to reach 1,500 rides on September 1, 2019.

The red dots ????.show the adjusted daily ridership we want to achieve to meet our Sep.

1, 2019 target.

Here’s an zoomed-in version:Zoomed In: The red dots ????.show the adjusted daily ridership we want to achieve to meet our Sep.

1, 2019 target.

You’ll see that some adjusted daily ridership projections are below the Prophet model’s original projections.

This is just one sample out of 1,000 samples generated, and so the model will produce some extreme data points.

However, the adjusted ridership projection predicts on average 13 daily rides more than the original projection.

And each day’s adjusted projection will take seasonality and holidays into account to produce more reliable, plausible daily forecasts.

To prevent the sales team from working with data points below the original projection, the original and adjusted ridership projections can be mashed together such that on any particular date, if the original ridership projection is higher than the adjusted projection, you keep the original value, and vice versa.

That produces what I’ve (just decided to) call a “high target” projection — something ambitious the sales team can aim for.

Three projections!.????.Original, adjusted, and a “high target” projection.

“High target” projections are one way of handling adjusted forecasts with more extreme individual data points, but I’m sure there are many different approaches that can be used here!.Monthly goals are easy to do, too — just subset thepredictive_samples() result by the rows corresponding to the month you’re interested in, sum the daily values across the rows for each of the 1,000 column (samples), and find the one closest to the target value.

This was a simple example using a basic Prophet model, but the use of predictive_samples() becomes more powerful as the underlying Prophet model gets better-tuned by setting additional parameters.

Overall, Prophet’s an impressively simple forecasting tool that packs a punch and allows you to extract goal-based projections that meet a particular target, which is a deliverable business teams are often asking for!Are there other ways to produce goal-based forecasts?.Please share below.

Note: This post was inspired by this clumsily-written question I asked in this Github issue — thanks to Ben Letham for pointing me in the right direction!.All R scripts (using tidyverse code), data, and figures are available at my Github repo.

.

. More details

Leave a Reply