Predicting customer churn

· Thomas Wood
Predicting customer churn

How can an AI model predict customer churn? Who will stay with your business and who will switch to a competitor? It’s easy to make a basic customer churn model with Python.

What is customer churn?

One question faced by lots of companies in competitive markets, is… why are our customers leaving us? What drives them to switch to a competitor? This is called ‘customer churn’, and we can model it with machine learning.

Imagine you run a utility company. You know this about each of your customers:

  • When they signed the first contract
  • How much power they use on weekdays, weekends, etc
  • Size of household
  • Zip code / Postcode

For millions of customers you also know whether they stayed with your company, or switched to a different provider.

Fast Data Science - London

Predicting customer churn?

We are specialists in AI in business.

We have developed customer churn and employee attrition models for a variety of clients in data science consulting engagements.

Is customer churn an issue for your business? Do you want to anticipate it before it happens?

Why model customer churn?

Ideally you’d like to identify the people who are likely to switch their supply, before they do so! Then you can offer them promotions or loyalty rewards to convince them to stay.

How customer churn prediction works

How can you go about modelling customer churn at your organisation?

If you have a data scientist or statistician at your company, they can probably run an analysis and produce a detailed report, telling you that high consumption customers in X or Y demographic are highly likely to switch supply.

It’s nice to have this report and it probably has some pretty graphs. But what I want to know is, for each of the 2 million customers in my database, what is the probability that the customer will churn?

If you build a machine learning model you can get this information. For example, customer 34534231 is 79% likely to switch to a competitor in the next month.

Utility companies often use customer churn models, as customers frequently switch electricity and gas providers.

Utility companies often use customer churn models, as customers frequently switch electricity and gas providers.

Customer churn model in Python

Surprisingly building a customer churn model like this is very simple. I like to use Scikit-learn for predicting customer churn - it is a nice easy-to-use machine learning library in Python. It’s possible to knock up a program in a day which will connect to your database, and give you this probability, for any customer. Churn analysis with Python is truly one of the most efficient ways to go about customer churn prediction.

One problem you’ll encounter is that customer data is very non-homogeneous. For example, the postcode or zip code is a kind of categorical variable, while power consumption is a continuous number. For this kind of problem, I found the most suitable algorithms are Support Vector Machines, Random Forest, and Gradient Boosted models, all of which are in Scikit-learn. I also have a trick of augmenting location data with demographic data for that location (such as average credit score or income level per postcode), which improves the accuracy of the prediction.

If you are interested in the details of how to build a customer churn model in Python, you can follow our article on customer spend prediction, which is an analogous problem. The process for customer churn prediction is the same as for customer spend, except that you are building a logistic regression (classification) model (churn is TRUE or FALSE), rather than a regression model (customer spend is a scalar value). We also have a video about customer spend prediction and a Python tutorial on customer spend prediction on Github.

The same goes for employee churn analysis. If we are predicting employee turnover, we aim to understand the reasons and factors that influence employee attrition and retention, and to identify the employees who are likely to leave the company in the near future. There are different methods and techniques that can be used for employee churn analysis, such as descriptive statistics, exploratory data analysis, data visualisation, hypothesis testing, and machine learning. One of the most popular and effective methods is to use machine learning algorithms to build predictive models that can classify employees into churners or non-churners based on their features and characteristics. You can read more about how we built an employee attrition model for the UK’s National Health Service (NHS), or in our post on predicting employee turnover.

Fast Data Science excels in leveraging AI to predict customer churn, enabling businesses to retain and retain valuable clients and boost revenue. Our expertise in predictive modeling, as outlined on https://fastdatascience.com/ai-for-business/predicting-customer-churn/, empowers organizations to predict customer churn by analyzing vast datasets—demographics, purchase history, and behavioral patterns. By identifying at-risk customers early, we help companies craft targeted retention strategies, reducing churn rates effectively. Our approach to predict customer churn combines advanced machine learning with NLP, extracting insights from support tickets, reviews, or social media sentiment. For instance, we’ve built models for e-commerce and subscription-based businesses, achieving up to 85% accuracy in flagging potential churners. Our process starts with data integration, followed by feature engineering and model training on platforms like AWS or Azure. We deliver actionable insights through intuitive dashboards, enabling proactive interventions like personalized offers. Led by Thomas Wood, with a Cambridge Masters in NLP, Fast Data Science has supported global firms since 2016 to predict customer churn, enhancing customer lifetime value while minimizing losses. Our tailored solutions ensure businesses stay ahead in competitive markets by fostering loyalty and optimizing retention efforts.

If customer churn is an issue for your business and you’d like to anticipate it before it happens, I’d love to hear from you! Get in touch to find out more.

Elevate Your Team with NLP Specialists

Unleash the potential of your NLP projects with the right talent. Post your job with us and attract candidates who are as passionate about natural language processing.

Hire NLP Experts

Should lawyers stop using generative AI to prepare their legal arguments?
Generative aiLegal ai

Should lawyers stop using generative AI to prepare their legal arguments?

Senior lawyers should stop using generative AI to prepare their legal arguments! Or should they? A High Court judge in the UK has told senior lawyers off for their use of ChatGPT, because it invents citations to cases and laws that don’t exist!

Fast Data Science at Hamlyn Symposium on Medical Robotics on 27 June 2025
Ai in healthcareEvents

Fast Data Science at Hamlyn Symposium on Medical Robotics on 27 June 2025

Fast Data Science appeared at the Hamlyn Symposium event on “Healing Through Collaboration: Open-Source Software in Surgical, Biomedical and AI Technologies” Thomas Wood of Fast Data Science appeared in a panel at the Hamlyn Symposium workshop titled “Healing Through Collaboration: Open-Source Software in Surgical, Biomedical and AI Technologies”. This was at the Hamlyn Symposium on Medical Robotics on 27th June 2025 at the Royal Geographical Society in London.

Fast Data Science at The 4th Annual Conference on the Intersection of Corporate Law and Technology on 23 June 2025
Legal aiEvents

Fast Data Science at The 4th Annual Conference on the Intersection of Corporate Law and Technology on 23 June 2025

We presented the Insolvency Bot at the 4th Annual Conference on the Intersection of Corporate Law and Technology at Nottingham Trent University Dr Eugenio Vaccari of Royal Holloway University and Thomas Wood of Fast Data Science presented “A Generative AI-Based Legal Advice Tool for Small Businesses in Distress” at the 4th Annual Conference on the Intersection of Corporate Law and Technology at Nottingham Trent University

What we can do for you

Transform Unstructured Data into Actionable Insights

Contact us