# Forecasting SaaS Product Usage

A usage forecast is a useful tool to have. Setting reasonable expectations about future usage can help you evaluate if the growth your seeing is normal or exceptional. But coming up with a reasonable forecast can be tricky - especially with products or services that have seasonal usage.

Many products experience repeated fluctuations and seasonality in their usage. Products targeting office workers experience many such patterns at different levels:

• Usage is focused within the day to office hours (say 8.am to 6.pm)
• Usage is much higher Mon-Fri with lower usage over the weekend
• Holidays periods (e.g. December, July & August) have lower usage

And so with these seasonal changes, it can be hard to tell if the low usage you’ve seen in August is normal or something to worry about.

Another factor is that products in a growth phase will experience more users as a result of new sales and new user acquisition. This again can make it hard to set expectations and explain high usage figures - had a great October? Is it a great as you’d expect?

## Forecasting with Prophet

Back in 2017, Facebook opensourced a great forecasting tool - Prophet. It’s optimised for business forecasting, and deals with the seasonality and usage trend problems we’ve explored above. It’s got implementations for R and Python, so fairly easy to work into your analytics process.

Installing for use with Python is as easy as:

pip install fbprophet


That should install prophet and all the required dependencies.

## A worked example

Here’s some fictitious usage data for a SaaS application. It’s an enterprise tool, so the data exhibits many of the seasonal usage trends which make forecasting a problem.

Let’s look at the monthly usage of the service for the past few years:

You can see, usage is going up (woo!), but it has some regular monthly fluctuations.

To run the forecast, the following code is needed. It assumes we have our usage data in a simple pandas dataframe with two columns: * Month (a datetime) * Sessions (an integer, the number of sessions in that month)

Assume you have a csv file with the total number of sessions each month for the past few years. We’ll read it in, rename the columns to meet prophets requirements and then fit the model to the data. We’ll for forecast 18 months.

# Read in a csv of monthly usage data with columns for 'Month' and 'Sessions'

# Ensure columns have correct names for prophet
df.columns = ['ds', 'y']

# Build the forecast
m = Prophet()
m.fit(df);

future = m.make_future_dataframe(periods=18, freq='M')
future.tail()

forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()

# Plot the forecast
fig = m.plot(forecast, xlabel='Date', ylabel='Sessions');
plt.title('Forecast usage')


The plot output is great, it shows the prediction and error margins based on the historic data. You can see where the historic monthly totals were by the small black dots - this is useful to see how the model has managed to fit the data.

You can also view some of the inner workings of the model, showing the trend and seasonality predicted by the model.

m.plot_components(forecast)


So now we have some predicted numbers for our future product usage! Next month, when we see the actual usage, we can compare against the forecasted usage and use this as a benchmark for how we are doing.