Loading
Data Science and Machine Learning

Predicting Retail Spending with Automated Feature Engineering

2026-08-25

Predicting Retail Spending with Automated Feature Engineering
A lightweight machine learning workflow that uses automated feature engineering to predict whether retail customers will become high spenders in the following month.

Retail transaction data contains valuable signals about customer behaviour, but converting thousands of individual purchases into useful machine learning features can be time-consuming. This project explores a lightweight approach to predicting future retail spending using automated feature engineering.

The analysis uses the Online Retail dataset, containing more than 540,000 transaction records with information such as customer ID, product, quantity, unit price and purchase date.

The prediction task is designed as a classification problem:

Will a customer spend more than £500 in the following month?

Rather than manually creating a large number of customer metrics, Featuretools is used to automatically generate behavioural features from historical transactions. Useful features include purchase frequency, total quantity purchased, total spending, average order value and maximum transaction value.

To keep the workflow efficient, the feature generation process is intentionally limited to a small set of aggregation primitives such as:

  • COUNT
  • SUM
  • MEAN
  • MAX
  • MIN

Time-based cutoff points are used so that only information available before the prediction date contributes to each feature. This helps prevent data leakage and better reflects how the model would operate in a real-world environment.

The generated customer-level feature matrix is then used to train a Random Forest classifier. Historical periods are used for training, while a later month is reserved for testing, creating a more realistic past-to-future evaluation.

Model performance can be evaluated using ROC-AUC, precision, recall and F1 score. Feature importance is also examined to understand which aspects of customer behaviour contribute most strongly to predicted future spending.

The project demonstrates how automated feature engineering can simplify a traditional data science workflow while still preserving important concepts such as temporal validation, leakage prevention and interpretable customer-level features.

Instead of generating hundreds of complex variables, the streamlined approach focuses on a smaller number of meaningful behavioural signals. This reduces memory usage, computation time and overall model complexity while retaining the core value of automated feature engineering.