Who's About to Leave? Predicting Bank Customer Churn with Machine Learning
Some of the customers most likely to leave a bank are the ones with the most money in their accounts. That was one of the more counterintuitive findings from a project I built to predict customer churn, and it's a good example of why this problem is worth solving with data rather than intuition.
Why churn is worth predicting
Churn, customers leaving - is one of the most expensive problems a business faces, because acquiring a new customer almost always costs more than keeping an existing one. The challenge is timing. By the time a customer has actually left, it's too late to do anything about it. The real value isn't in knowing how many customers churned last year; it's in knowing which customers are likely to churn next, while there's still time to act. That's a prediction problem, and it's exactly the kind of question machine learning is built to answer.
The project
I worked with a dataset of 10,000 bank customers, each described by 12 features: credit score, age, account balance, tenure, country, gender, number of products held, and whether they ultimately stayed or left. The goal was to train a model that could look at a customer's profile and estimate how likely they are to leave. I built and compared two models:
Logistic Regression - a simple, interpretable baseline. It reached 80.5% accuracy.
Random Forest - a more powerful model that combines many decision trees. It reached 85.7% accuracy.
Why accuracy isn't the whole story
Accuracy alone can be misleading for a problem like this. Most customers don't churn, so a lazy model that simply predicts "everyone stays" would still look fairly accurate, while being completely useless, because it never flags anyone to save. The number that actually matters is how many real churners the model catches. The gap between the two models was particularly striking here: out of 407 customers who actually left, Random Forest correctly identified 175 of them, while Logistic Regression caught only 58. For a retention team, that's the whole game, you can only save the customers you can see leaving.
What the model revealed
Beyond the predictions, the model surfaced clear patterns about who leaves:
Age was the single strongest predictor, accounting for roughly 25% of the model's decision-making. Customers in their 40s and 50s churned far more than younger ones.
German customers left at about twice the rate of French and Spanish customers.
Higher-balance customers were more likely to leave, the counterintuitive finding. Customers with money in their accounts have more options and make more attractive targets for competitors.
Put together, these draw a clear profile of the at risk customer: older, higher-balance, often holding only a single product, and concentrated in certain markets more than others.
From prediction to action
Instead of spreading a retention budget thinly across the entire customer base, a bank could focus its efforts on the few hundred customers the model flags as genuinely at risk, offering them targeted incentives, additional products, or personal outreach before they leave. The analysis even points to a specific lever: single-product customers are at higher risk, so encouraging them to adopt a second product would likely reduce churn. That's the shift that makes applied machine learning valuable, it turns 10,000 rows of historical data into a focused, actionable decision.
Under the hood
The project was built in Python, using pandas and NumPy for data work, scikit-learn for the models, and matplotlib and seaborn for visualization, all in a Jupyter notebook. The full code, analysis, and results are available on GitHub:
github.com/naumenko-analytics/bank-churn-prediction
Predicting churn is one example of the applied analytics work I do at Naumenko Analytics, turning business data into decisions teams can act on. If you're working on a similar problem, I'd be glad to talk.