Category Archive Time series

Earlier I wrote another post about predicting the spend of a single known customer. There is a related problem which is predicting the total spend of all your customers, or a sizeable segment of them.

Time series approach: segments of customers

If you don’t need to predict the spend of an individual customer, but you’re happy to predict it for groups of customers, you can bundle customers up into groups. For example rather than needing to predict the future spend of Customer No. 23745993, you may want to predict the average spend of all customers in Socioeconomic Class A at Store 6342.

In this case the great advantage is that you would not have so many empty values in your past time series. So your time series may look like this:

This means you can use a time series library such as Prophet, developed by Facebook.

Here’s what Prophet produces when I give it the data points I showed above, and ask it to produce a prediction for the next few days. You can see that it’s picked up the weekly cycle correctly.

This approach would be very useful if you only needed the data for budgeting or stock planning purposes for an individual store and not for individual customers.

However if you had small enough customer segments, you may find that the prediction for a customer’s segment is adequate as a prediction for that customer.

Multilevel models

The next step up in complexity is multilevel models, where you use a different level of model for each region or economic group of customers, and combine them into a single group model.

Combinations

To get the maximum predictive power you can try ways of combining time series methods with a predictive modelling approach, such as taking the results of a time series prediction for a customer’s segment and using it as input to a predictive model.

Getting started

If you have a prediction problem in retail, or would like to some help with another problem in data science, I’d love to hear from you. Please contact me via the contact form.

The simplest way would be to use a predictive modelling machine learning approach. For example you could use Linear Regression. If you are unfamiliar with how to do this I recommend Andrew Ng’s Coursera course.

You would provide as input to your Regression model:

Last purchase value (if available)

Second last purchase value (if available)

Third last purchase value (if available)

The output you want it to predict is:

The next purchase value

This will predict the next purchase with some accuracy. After all the biggest factor to predict what someone will buy, is what they bought in the past.

However I’m sure you can easily think of some cases where this will break down. For example

A customer with no past purchases

Over Christmas if purchases tend to be bigger

You can improve the performance of the Predictive Model approach by making it a little more sophisticated:

Add more input features to the Regression model such as “day of week”, “day of year”, “isChristmasSeason” etc.

Switch to a Polynomial Regression Model, or Random Forest Regression. This will allow your model to become more powerful if the relationships between your inputs and outputs are not entirely linear, although it comes with a risk of your predictions going a crazy (like predicting huge numbers) if you are not careful!

Make different models

Getting started

If you have a prediction problem in retail, or would like to some help with another problem in data science, I’d love to hear from you. Please contact me via the contact form.