Analytics

An easier way to make Machine Learning forecasts smarter

1 year ago

Recently we’ve spoken a lot about forecasting (see The Good, the Bad and the Unpredictability of SEO Forecasting, and Forecasting & the Importance of Uncertainty). If forecasting is your thing, then you’re in luck, because this post continues with that theme.

Have you ever been in a situation where you put together a forecast for the coming year, but after you agree to it with your boss you realise you’ve just missed an important peak period and now you can never meet your KPIs?

Or have you ever tried to put together a forecast, but realised you’re spending ages figuring out what “average” performance actually is?

Or have you tried using a forecasting tool, and found that no matter how hard you try - the numbers it returns are wildly optimistic or pessimistic, and you can’t convince it to pay attention to the right trends?

If so - this post is for you!

To set the scene for this blog - there are a couple of main approaches to forecasting:

  1. Pattern-Based Forecasting - This involves looking at past performance (seasonal patterns, year-on-year growth etc.) and assuming the future will follow the same patterns. An example of this is Facebook Prophet.
  2. Plan-Based Forecasting - This involves assuming something will change in the future and estimating future performance based on that. An example of this is making a keyword list, and estimating the extra conversions you could get from targeting those keywords.

Pattern-based forecasting isn’t great at factoring in changes (i.e. you implementing a new marketing strategy) and plan-based forecasting isn’t great at factoring in things like the seasonal variations we know come up every year.

In order to get the best of both worlds, we need to combine pattern-based mathematical insights about ‘seasonality’ with our plan-based knowledge of what we’re going to change, and what YoY trends are reasonable. We’ll explain below in more detail why you need that combination.

In the past, that would have been a real pain, but we’re going to show you how to do just that. We’re also sharing this Free Google Sheet to help you.

Gif of the sheet - all of the standard seasonality and year-on-year trend calculations are done but you can quickly adjust the graph to align with what you think is sensible.

Pattern-based forecasting

The importance of pattern-based forecasting in understanding seasonality

Businesses need seasonality in forecasts because:

  1. It helps reduce time spent wondering why the actual figure is much higher/lower than the forecast.
  2. If we don’t factor in seasonality - we can miss warning signs that the high period actually wasn’t as high as it needed to be to meet our targets, or we could accidentally miss the high period entirely.

If we are selling Halloween costumes on our ecommerce website, our forecast should be able to predict the spikes in traffic in the build-up to Halloween. Not only because we want to prepare for that period, but also because, if Halloween is quieter than we expect, we need to look at the rest of the year to figure out how we’re going to make up the shortfall.

In the case of a Halloween shop this is pretty simple but, for many websites, there are numerous peaks and troughs throughout the year which would be really challenging to factor in manually.

Alongside this type of seasonality, there may be numerous other external factors which may be impacting traffic such as new competitors coming onto the market, changes in pricing and strategy, or external events (such as COVID).

Pattern-based forecasting tools such as Prophet help us identify seasonal patterns without having to spend hours figuring out if April is always a low month, or whether March and May are high months, and whether we should expect all three of them to be even higher or even lower next year.

These pattern-based forecasts, though, make some unwise assumptions.

Pattern-based forecasts rely on using historical data to find seasonal effects, and then apply those seasonal effects to the future. The other key component in these forecasts, though, is the year-on-year broader trend. This is a key way it can go wrong. 

Essentially, these tools figure out patterns like monthly or weekly seasonality and simultaneously try to figure out whether your numbers are growing or shrinking overall (i.e. should we expect Christmas next year to be bigger or smaller than Christmas last year).

What can happen is that these forecasts assume that the year-on-year broader trend, whether up, down or flat will continue indefinitely. For example, they can assume revenue will double every year even past your total market size.

See the example below with seasonality removed, so we can just see the trend.

Similarly, these forecasts can make unrealistic downward predictions (even dipping below zero) if the broader trend is in that direction.

Clearly, however strong the seasonality forecasting is from pattern-based forecasts, if the trend is painting a really unrealistic story, then the forecast is not particularly useful.

The funny thing is, we can look at those charts and see, at a glance, what’s wrong. We can probably even guess how to fix it, but it can be hard to communicate that to Prophet and other similar tools.

We need a way to be able to combine mathematical insights about ‘seasonality’ with the ability to set the trend based on our understanding of the business/ industry.

The ideal solution here is that you can combine: 

  • All the power of pattern-based forecasts and the machine learning that is used to understand the seasonality and wider patterns.
  • A strong dose of common sense so you can set the appropriate broader trend based on your knowledge of the business, market potential etc. in order to avoid unrealistic trend projections.

A baseline forecast

We can produce a baseline forecast by taking the outputs of a pattern-based tool like Prophet, stripping out the year-on-year (YoY) trend and just applying seasonality to our current performance. Essentially, it helps us create a picture of what the next year or two could look like if our performance stays just the way it is now.

If we think that stripping out YoY trends entirely is too far then we can just dampen it (maybe we say that the YoY trend for the next year will be half half as strong as predicted).

Because we can adjust the YoY trend without overwriting seasonality, it’s much easier to decide what the future realistically looks like if we change nothing about our current marketing.

Once you have this baseline forecast you then apply any additional increases you expect throughout the forecasting period (i.e. from building new pages in SEO or running a paid media campaign).

From there you have your “final forecast” which is basically: 

Final Forecasted Figures = Baseline Forecast Figures + Additional Figures

  • Blue Line - Baseline Conversions
  • Red Line - Baseline Conversions + Additional Projected Conversions.

Baseline forecasts can help you to avoid missing periods where there are likely to be peaks and troughs. For example, if you’re planning out your marketing activity, using a baseline forecast will help you to understand seasonality so you plan activities around the high points, as opposed to the low points (or vice versa).

Using our solution

If you don’t need any more information and you just want to start using the sheet we put together, here it is.
There are a bunch of instructions in there for you to follow but broadly:

  1. Run a forecast in Prophet (Facebook has given a how-to here. Robin also covers this in his on-demand Python course)
  2. Take the output forecast (every column) and paste it into the tab named Step 1 - Copy & Paste Prophet Output
  3. Adjust the % in Output 1 - Graphs to see your forecast line move up and down
  4. Take the figures from Output 2 - Raw Data to use as a baseline to combine with your plan-based forecast

 What is our solution for building a more reliable baseline forecast?

Knowing the limitations of pattern-based forecasting, it’s important to build a baseline forecast that accounts for seasonality that isn’t so heavily impacted by the overall trend.

This prevents either:

  • Creating a too-optimistic baseline forecast with growth expected to continue at unrealistic levels.
  • Creating a too-pessimistic baseline forecast where the predicted values go below levels that we’d expect.

It’s tough to strike a balance between a forecast that takes into account the broader trend, but doesn’t create unrealistic predictions. It takes knowledge of the business and the market in which the business is operating, as well as an understanding of the website and the strategy that’s come before.

Let’s dive into how we’ve sought to address this using Facebook Prophet.

What goes into a Prophet forecast?

Prophet takes into account several components when making a forecast which are actually summarised in the outputs (see below). 

Prophet takes the historical data, breaks it down into these components and then combines those components together to get the output forecast:

Trend

It’s the overall long-term movement of the number you’re predicting, either upward, downward or flat. This is basically “How does Christmas next year compare to Christmas last year”.

Seasonality

This breaks down patterns that repeat over known, fixed periods of time, such as daily, weekly, or yearly cycles.

You’ll often see websites have more traffic at certain periods throughout the year and relative slumps throughout other parts of the year, and it’s important this is reflected in the forecast.

Weekly and yearly seasonality
Holidays and Events

This considers known special events or holidays that might cause unusual spikes or drops in the data such as Christmas, Easter, or more relevant business events that have a more significant impact on traffic, such as Black Friday.

Special events like Black Friday

Prophet takes the historical data, breaks it down into these components and then combines those components together to get the output forecast.

Finding a more realistic overall trend

When Prophet builds the final forecast it adds & multiplies together all of the numbers (trend, seasonality, etc.). The broader trend plays a significant role in the calculation. 

Fortunately for us, the difficult part is really the first step - splitting historic data into the individual patterns. Once we have those numbers combining them together to get the actual forecast is pretty simple maths. 

So, in order to create a more reasonable trend we can:

  1. Run prophet and get it to give us all of the numbers for each of those breakdowns (seasonal, trend etc.)
  2. Adjust the trend number however we like
  3. Use formulas in Google Sheets to replicate what Prophet does in the final step, except we combine our new adjusted trend with the other data

As a sense-check we can compare our adjusted forecast with:

  1. The “Pure Trend” Forecast - the standard Prophet output with no adjustments. The trend is not capped in any way, and the weekly, monthly, and yearly seasonality is applied across the forecast. This is pretty much exactly the output you’d normally get from Prophet.
  2. The “Zero Trend” Forecast - We basically flatten the “Trend” and then apply that to the rest of the forecasting period. This essentially means we are assuming no year-on-year (YoY) change, but the weekly and monthly seasonality is still applied across the forecast. 

Being able to adjust our forecast to fall between the “Zero Trend” and “Pure Trend” options lets us model a more balanced view of the future, handling any of the more unrealistic expectations.

When will this Google Sheet come in handy?

This approach is really useful if you are creating a forecast using Prophet, and you’re getting far too optimistic or pessimistic forecasts based on historical trends. 

This will allow you to use more of your own judgement in order to set a reasonable level between the “pure” forecast (with no adjustment to the trend) and a version of the forecast with trend capped.

In conclusion

As lots of people have said before, forecasting is more art than science. It requires a lot of understanding from a business. Pattern-based tools like Prophet are a fantastic way to break down patterns in numbers, but it’s important for us to have an easy way to handle any weird assumptions those tools might make. At the end of the day - Prophet doesn’t know your business, you do, and so we’re really glad to share a way for you to have more control over how your forecasts come together.

We’d love to hear your thoughts, feel free to reach out on Twitter to @airadigital and @da_westby

Download our credentials deck.

Pop it in my inbox.
Analytics

Getting started is as easy as having a conversation.

crosschevron-down