Predicting Bank Customer Churn with Agentic AI: What 10,000 Customer Records Taught Us About Retention
Customer churn is one of the most expensive problems in retail banking. Acquiring a new customer costs far more than keeping an existing one, which makes spotting at-risk customers early a top strategic priority. We analyzed 10,000 bank customer records using the Terno Agentic AI platform — connected directly to a MySQL database hosted on Aiven Cloud Data Services — to find out exactly which customers are leaving, and why.
The headline finding: roughly one in five customers (20.37%) has already exited the bank, and churn rates swing dramatically depending on geography, age, and account activity. That means retention budgets spent evenly across the whole customer base are likely wasted — the money should be concentrated on a few specific, identifiable segments.
Here's everything we found, and what to do about it.
Key Takeaways Up Front
The dataset shows an imbalanced 80/20 split between retained and churned customers, which has real consequences for how prediction models need to be built.
Age and member activity status are the two strongest predictors of churn.
Germany churns at roughly double the rate of France and Spain.
Machine learning classifiers hit up to 86.65% accuracy and 0.8612 ROC-AUC at predicting who will leave.
All charts below were generated interactively inside Terno's agentic AI environment, querying live data with no manual exports.
Data & Methodology
The Dataset
We worked with the Bankdata customer churn dataset, sitting in a MySQL relational database and accessed through Terno AI's live database connector. The data infrastructure runs on Aiven Cloud Data Services, giving us managed, secure, scalable MySQL hosting. Terno AI connected directly to this cloud database, running real-time SQL queries with no manual exports and no pipeline lag.
The dataset covers:
Sample size: 10,000 validated customer records from the
churn_datatableDemographics: gender, age, surname, geography (France, Germany, Spain)
Financial attributes: credit score, account balance, estimated salary, number of products held
Behavioral indicators: tenure, active member status, credit card ownership
Target variable: binary churn outcome (Exited: 1 = churned, 0 = retained)
Technology stack: The churn_data table lives in a MySQL instance provisioned through Aiven Cloud Data Services — a fully managed open-source data platform with automated backups, high availability, and enterprise-grade security. Terno Agentic AI connected to this database via its native database integration layer, running every analytical query directly against the live MySQL instance (Dataset ID: 677). No pipeline delays, no stale data — every result reflects the current operational database.
Our Five-Phase Analytical Framework
- Initial Exploration — row/column counts, data type verification, schema review, sample inspection
- Data Quality Assessment — missing value checks, duplicate detection, unusual value identification across all fourteen columns
- Univariate & Segmentation Analysis — churn distribution, age profiling, balance comparison, geographic breakdown, behavioral factor evaluation
- Correlation Analysis — a numerical feature correlation heatmap highlighting variables most related to churn
- Predictive Modeling — development and comparison of Logistic Regression, Random Forest, and XGBoost classifiers
Consistent train/test splits and encoding strategies were used throughout to keep model comparisons fair.
Data Preprocessing
Before modeling, we:
Removed non-predictive identifiers (RowNumber, CustomerId, Surname)
Converted types — Balance and EstimatedSalary parsed from object strings to numeric format
Checked for missing data — zero missing values across all 14 columns; no imputation needed
Encoded categories — one-hot encoding of Geography and Gender with first-level dropping to avoid multicollinearity
Scaled features — StandardScaler normalization applied to numeric columns for Logistic Regression training
Split the dataset — a stratified 80/20 partition yielding 8,000 training observations and 2,000 validation cases
Customer Demographics & Profile
Overall Churn Distribution
The class distribution is meaningfully imbalanced: most customers stay, but a substantial minority have left.
Operational concern: With 20.37% of customers churned, the bank faces a material retention challenge. That imbalance also has direct modeling implications — standard classifiers trained without adjustment will inherently bias toward predicting retention, letting at-risk customers slip through undetected.
| Status | Count | Percentage |
|---|---|---|
| Not Churned | 7,963 | 79.63% |
| Churned | 2,037 | 20.37% |
| Total | 10,000 | 100% |
Gender: Not a Differentiator
Gender-based churn analysis shows male and female customers exhibit similar overall churn tendencies. Neither gender stands out as a dominant at-risk segment — retention strategies don't need to be gender-differentiated, and should instead focus on behavioral and financial attributes.
The Age Factor
Age is one of the most discriminating variables in the dataset. Churned customers average 44.84 years old, versus 37.41 years for those who stay — a gap of over seven years. Churned customers cluster in the 40–60 age band, while the retained majority peaks at 30–40.
Retention priority: Customers aged 40 and above warrant enhanced engagement programs. This cohort likely has accumulated assets elsewhere, has greater financial literacy for comparing offerings, and may be less price-sensitive but more quality-sensitive — demanding relationship-grade service that standard retail banking products often fail to deliver.
| Churn Status | Average Age (Years) |
|---|---|
| Not Churned | 37.41 |
| Churned | 44.84 |
Financial Patterns & Segmentation
Account Balance: A Counterintuitive Signal
Balance analysis challenges conventional assumptions about high-value customer loyalty. Churned customers show a wider balance range with a higher median — elevated account value does not confer loyalty.
Churned customers: average balance $91,108.54 | median $109,349 | Q3 $131,435 | max $250,898
Retained customers: average balance $72,745.30
Strategic implication: High-balance customers likely have superior financial sophistication and awareness of competing offers. They may perceive insufficient return on deposits, inadequate personalized service, or better yield opportunities elsewhere. Retention incentives — preferential interest rates, dedicated relationship managers, premium product access — should be concentrated on this high-value segment before exit signals appear.
| Churn Status | Average Balance (USD) |
|---|---|
| Not Churned | 72,745.30 |
| Churned | 91,108.54 |
Geographic Segmentation: The Germany Anomaly
Geographic breakdown uncovered a stark regional disparity. Germany's churn rate of 32.44% is roughly double that of France (16.15%) and Spain (16.67%).
| Geography | Total Customers | Churned | Churn Rate |
|---|---|---|---|
| Germany | 2,509 | 814 | 32.44% |
| Spain | 2,477 | 413 | 16.67% |
| France | 5,014 | 810 | 16.15% |
This regional concentration suggests either product-market fit issues specific to Germany, competitive pressure from local banking alternatives, or service delivery gaps affecting German customers disproportionately.
Regional intervention required: Germany should be treated as a priority market for retention programs. Root cause investigation — through customer exit surveys, competitive benchmarking, and product utilization analysis — should precede any broad marketing spend in this region.
Behavioral Factors: Activity Status and Credit Cards
Two behavioral dimensions were tested for their independent relationship with churn — and the results diverge sharply.
| Activity Status | Total Customers | Churned | Churn Rate |
|---|---|---|---|
| Inactive Members | 4,849 | 1,302 | 26.85% |
| Active Members | 5,151 | 735 | 14.27% |
| Card Status | Total Customers | Churned | Churn Rate |
|---|---|---|---|
| No Credit Card | 2,945 | 613 | 20.81% |
| Has Credit Card | 7,055 | 1,424 | 20.18% |
Two clear conclusions emerge:
- Member activity is critical. Inactive members churn at 26.85% versus 14.27% for active members — a 12.6 percentage point gap. Engagement and product utilization are powerful retention levers.
- Credit card ownership is negligible. A 0.63-point difference in churn rates between cardholders and non-cardholders shows that credit card products alone don't meaningfully bind customers to the institution. Bundled product depth, not card issuance, likely determines loyalty.
Strategic Drivers: Root Cause Analysis
The "Engagement-First" Reality
Conventional banking wisdom emphasizes product breadth and rate competitiveness as the primary retention mechanisms. Our correlation and feature importance analysis challenges that assumption, surfacing behavioral engagement and demographic age as the dominant churn predictors instead.
Key correlation findings:
- Age (r ≈ 0.285, positive): The strongest numerical predictor of churn. Older customers churn at higher rates regardless of balance size or product holdings — underscoring the importance of life-stage-aligned banking products.
- IsActiveMember (r ≈ −0.156, negative): Member engagement negatively correlates with churn — customers who actively use accounts, transact regularly, or interact with bank services are substantially less likely to exit. This relationship is causal and directly actionable.
- Balance (r ≈ 0.119, moderate positive): Higher balances weakly but consistently associate with increased exit probability, reinforcing the high-value customer vulnerability finding from segmentation.
- NumOfProducts (r ≈ −0.048, non-linear pattern): Customers with two products show the lowest churn rates, while those with three or more products show elevated exit behavior — suggesting over-selling or product mismatch drives dissatisfaction rather than loyalty.
- CreditScore, EstimatedSalary, Tenure: Weaker or negligible standalone correlations with churn, though they contribute meaningfully within ensemble models.
Investment reorientation: Rate competition and product proliferation may deliver less retention improvement per dollar than engagement programs, life-stage advisory services, and proactive outreach for inactive account holders. This finding carries profound budget implications for retail banking strategy.
Predictive Modeling: The Machine Learning Approach
Beyond understanding current churn drivers, we built computational models to forecast individual customer exit probability — enabling preemptive retention intervention before customers disengage for good.
The Classification Problem
We framed churn forecasting as binary classification:
Input variables (X): credit score, geography, gender, age, tenure, balance, number of products, credit card status, activity status, estimated salary
Output variable (y): binary churn state (Exited = 1 or 0)
Learning goal: derive a function f: X → y that generalizes to previously unseen customers
Three Models, Three Approaches
- Logistic Regression — a linear probability framework offering coefficient interpretability and a baseline benchmark
- Random Forest — a tree ensemble using bootstrap aggregation to minimize variance while capturing non-linear feature interactions
- XGBoost — sequential gradient-boosted trees that iteratively correct prior model errors for superior pattern recognition
Baseline Model: Logistic Regression
Overall accuracy: 81.15%
Precision (churned): 0.5563
Recall (churned): 0.2010
F1 score (churned): 0.2953
ROC-AUC: ≈ 0.70
Classification matrix:
| Actual / Predicted | Not Churned | Churned |
|---|---|---|
| Not Churned | 1,544 | 63 |
| Churned | 314 | 79 |
Though it delivers solid baseline accuracy with transparent coefficients, the logistic model's low recall of 20.10% for churned customers is operationally problematic — it misclassifies the majority of actual churners as retained. This gap reflects both class imbalance and non-linear relationships that linear models can't fully capture.
Advanced Model: Random Forest
Random forest builds numerous decision trees independently, then aggregates their predictions through majority voting. The feature importance chart below closely mirrors our earlier correlation findings.
Overall accuracy: 86.65%
Precision (churned): 0.7582
Recall (churned): 0.4707
F1 score (churned): 0.5808
ROC-AUC: ≈ 0.8500
The jump in recall — from 20.10% to 47.07% — and F1 score — from 0.2953 to 0.5808 — shows Random Forest's clear edge at identifying at-risk customers, which is the core operational goal of any churn prediction system.
State-of-the-Art Model: XGBoost
XGBoost represents current best practice in gradient boosting, offering computational efficiency alongside superior predictive performance.
Overall accuracy: 86.55%
ROC-AUC: ≈ 0.8612 — the strongest discrimination score across all models tested
That 0.8612 ROC-AUC shows a strong ability to distinguish churners from non-churners across all classification thresholds, making XGBoost particularly suitable for threshold-tuning applications where recall can be prioritized over precision depending on intervention cost economics.
Model Comparison & Selection
| Algorithm | Accuracy | Precision | Recall | F1 Score | ROC-AUC |
|---|---|---|---|---|---|
| Logistic Regression | 81.15% | 0.5563 | 0.2010 | 0.2953 | ≈ 0.70 |
| Random Forest | 86.65% | 0.7582 | 0.4707 | 0.5808 | ≈ 0.85 |
| XGBoost | 86.55% | — | — | — | ≈ 0.8612 |
Production recommendation: XGBoost demonstrates the strongest ROC-AUC (0.8612), indicating superior class discrimination capability. For operational deployment, XGBoost combined with probability threshold tuning — rather than a default 0.5 cutoff — will optimize the precision/recall trade-off based on the bank's retention intervention cost structure.
Feature Importance Summary
The Random Forest feature importance chart (Figure 8) corroborates all prior analytical findings, producing a consistent ranked ordering:
- Age (≈ 0.23): Highest importance by a substantial margin — the primary churn driver across all analytical methods
- EstimatedSalary (≈ 0.15): Second-ranking position in the ML importance hierarchy
- CreditScore (≈ 0.15): Near-equal to EstimatedSalary — reflects financial health and alternative credit access as churn proxies
- Balance (≈ 0.14): Matches the segmentation hierarchy, reinforcing the high-value customer vulnerability finding
- NumOfProducts (≈ 0.13): Significant predictor, particularly through the non-linear churn relationship at higher product counts
- Tenure (≈ 0.08): Moderate contribution capturing relationship longevity effects
- IsActiveMember (≈ 0.04): Despite a strong segmentation signal, partially absorbed by correlated features in the ensemble context
- Geography_Germany, Gender_Male, HasCrCard (< 0.03): Lowest tier, though Geography_Germany's presence aligns with the documented regional disparity
This convergence between traditional statistical correlation and machine learning importance metrics strengthens confidence in the strategic recommendations below, since it's consistent across independent analytical methods.
Recommendations
Drawing from both correlation analysis and machine learning feature rankings, we recommend focused intervention in high-leverage customer segments rather than diffuse retention spending across the entire customer base.
1. Age-Segmented Engagement Programs
Justification: As both the strongest correlation (r ≈ 0.285) and the highest ML importance score (≈ 0.23), age-based segmentation is the single most impactful targeting criterion for churn prevention.
Implementation steps:
Cohort definition: flag customers aged 40+ as elevated-risk and auto-enroll them in proactive relationship management workflows
Product realignment:
- Develop life-stage-appropriate products (wealth management, retirement planning, estate services) for mid-career and pre-retirement priorities
- Assign dedicated relationship managers for customers aged 45+ with balances exceeding $50,000
- Launch advisory touchpoints (quarterly reviews, financial health checks) that reinforce relationship value
Success metric: target a 15% reduction in churn rate among the 40+ cohort within 12 months of launch
Projected impact: Even a 5-percentage-point reduction in the 40+ segment's churn rate could prevent hundreds of high-balance exits, preserving significant deposit volume and associated revenue.
2. Member Activation Campaign
Justification: Inactive members churn at nearly double the rate of active members (26.85% vs 14.27%). Converting inactive accounts into engaged ones is the highest-leverage behavioral intervention available.
Implementation steps:
Inactivity detection: define operational triggers for accounts with no transactions in 60-, 90-, or 180-day windows
Re-engagement sequences:
- Personalized outreach (email, push, SMS) highlighting underutilized product features
- Limited-period incentives (bonus interest rates, cashback, fee waivers) tied to activity milestones
- Route persistently inactive high-balance accounts to direct relationship manager outreach
Freemium activation architecture: offer complimentary premium service trials (priority customer service, premium card upgrades) to lapsed accounts, converting feature exposure into habitual engagement
Projected impact: Re-activating 20% of currently inactive at-risk customers could reduce overall churn by 2–3 percentage points, translating directly into retained deposit balances and cross-sell revenue.
3. Germany-Specific Retention Program
Justification: Germany's 32.44% churn rate — double that of France and Spain — demands targeted regional investigation and intervention independent of the global retention strategy.
Implementation steps:
Exit survey deployment: mandate structured exit interviews for German customer closures to identify primary departure reasons
Competitive intelligence: map the German banking landscape for recently launched competing products, rate improvements, or digital-native entrants attracting the churning cohort
Localized product development: consider Germany-specific innovations (higher-yield savings instruments, digitally-native account formats, local partnership integrations)
Churn prediction threshold adjustment: lower the ML model's intervention threshold for German customers from 0.7 to 0.5, triggering proactive outreach earlier in the exit journey
Projected impact: Reducing Germany's churn rate to match Spain's (16.67%) would retain approximately 395 additional customers annually — a material improvement given the elevated average balances observed among churned customers.
4. Predictive Intervention System
Justification: With XGBoost achieving 0.8612 ROC-AUC, the model can identify at-risk customers weeks before actual exit, creating intervention windows that reactive retention strategies can't access.
Implementation steps:
Real-time scoring pipeline: integrate the model into core banking CRM systems for weekly churn probability refresh, querying live data from the Aiven-hosted MySQL instance via Terno's database connector
Tiered intervention triggers:
- Probability 0.5–0.7: automated digital outreach (personalized email, in-app notification) with product recommendations
- Probability 0.7–0.9: relationship manager assignment with a defined contact obligation within 5 business days
- Probability above 0.9: senior advisor escalation with discretionary retention offer authority (rate enhancements, product upgrades, fee reversals)
Model maintenance: quarterly retraining with fresh customer data from the live Aiven MySQL database, keeping accuracy current as behavioral patterns evolve
Feedback loop: capture intervention outcomes (retained, churned despite intervention, declined contact) to continuously refine model training and intervention strategy
Projected impact: Proactive intervention on high-probability churners could prevent 15–25% of forecasted exits from materializing, preserving deposit volumes and relationship revenue that reactive approaches would otherwise lose entirely.
Conclusion
This analysis shows how modern agentic AI capabilities — connected directly to live cloud-hosted databases — turn operational banking data into strategic intelligence for customer retention. By linking Terno AI to a MySQL database hosted on Aiven Cloud Data Services, the whole workflow required no manual data exports, no pipeline engineering, and no batch processing delays: insights came straight from the source of truth.
Combining traditional statistical techniques, interactive visual analytics, and advanced machine learning surfaced five key findings:
- Churn driver identification: Age and member activity status are the dominant predictors, challenging the assumption that financial product breadth or rate competitiveness are the primary retention levers.
- Geographic disparity: Germany's churn rate of 32.44% is nearly double that of France and Spain, demanding a market-specific strategic response rather than a uniform global approach.
- High-value customer vulnerability: Customers with higher account balances churn at greater rates — a counterintuitive risk that conventional loyalty assumptions overlook.
- Forecasting capability: We achieved 0.8612 ROC-AUC prediction accuracy, enabling proactive rather than reactive retention strategies.
- Evidence-based prioritization: Quantitative analysis supports specific investment priorities — age-segmented engagement, activation campaigns, and regional programs — that maximize churn prevention relative to capital deployed.
Retail banking today sits at the intersection of relationship depth and digital convenience. This work gives institutions a quantitative framework for directing retention resources toward genuinely high-risk segments, anticipating customer exits through predictive intervention, and converting operational data into a sustainable competitive advantage in deposit retention.
Note: The dataset shows a 79.63% / 20.37% class imbalance. Teams extending this work are advised to apply SMOTE oversampling or scale_pos_weight class-weight adjustment in future optimization cycles to further improve recall on the minority churned class.
References & Methodology
This investigation employed contemporary agentic AI workflows ensuring analytical transparency and result reproducibility. Complete methodological details and source materials appear below:
- Terno.ai — Agentic AI Platform for Data Science Applications. Available at: https://terno.ai
- Complete Analysis Documentation: Full conversation history and computational steps recorded on Terno AI. https://manoj3.app.terno.ai/chat/share/9467979e-9444-42b1-aea9-b1a041d1697e?ui_version=v2
- Data Infrastructure: The churn_data table is stored in a MySQL relational database provisioned through Aiven Cloud Data Services (https://aiven.io) — a fully managed open-source data platform providing automated backups, high availability, end-to-end encryption, and multi-cloud deployment. Terno Agentic AI connected to this Aiven-managed MySQL instance (Dataset ID: 677) using its native database integration layer, enabling live SQL query execution without manual data extraction or pipeline configuration. The dataset was uploaded directly to MySQL and made available to Terno through this cloud-hosted connection.
- Computational Environment: Python 3.9+ employing scikit-learn (Logistic Regression, Random Forest, evaluation metrics), xgboost (gradient boosting), pandas (data manipulation), and matplotlib/plotly (interactive visualization generation). All charts and visualizations were generated natively within Terno's agentic AI environment and exported as HTML and PNG outputs.
- Dataset Source: Bank Customer Churn Dataset, churn_data table (10,000 validated customer records), uploaded to MySQL and hosted via Aiven Cloud Data Services. Dataset originally sourced from publicly available churn modeling benchmarks commonly referenced in financial analytics literature.
- Validation Approach: Standard machine learning evaluation employing Accuracy, Precision, Recall, F1-Score, ROC-AUC metrics, and Confusion Matrix analysis. Stratified 80/20 train-test split guarded against overfitting while ensuring robust performance estimation across both majority and minority classes.
- Class Imbalance Handling: Imbalanced class distribution (79.63% retained, 20.37% churned) noted throughout. Modeling teams are advised to apply SMOTE oversampling or
scale_pos_weightclass-weight adjustment in subsequent optimization cycles to further improve recall on the minority churned class.
See the complete analysis and conversation history on Terno AI: https://manoj3.app.terno.ai/chat/share/9467979e-9444-42b1-aea9-b1a041d1697e?ui_version=v2
*Read the full whitepaper*
18 August 2026
The Honest Number Was 83%: Leakage, Abstention, and a Complaint Router You Can Actually Deploy
The same complaint-routing model scores 96.3% or 83.2% depending on which three columns you leave in the training data. The high number is the intake form being read back to you. This is what the leakage audit found before a single model was trained, why 83.2% is the honest figure, and how the same model — given permission to say "I don't know" — becomes deployable at 90.7% accuracy on 79.5% of traffic.
29 July 2026
EdgeGuard: AI-Driven Predictive Maintenance for Power Transformers
Power transformers are among the most critical assets in electrical distribution infrastructure. Their unexpected failure can result in power outages, safety hazards, equipment damage, expensive repairs, and long service interruptions. Traditional transformer maintenance practices often rely on periodic manual inspection, offline testing, or run-to-failure maintenance. These methods are expensive, slow, labor-intensive, and unable to detect rapidly developing faults in real time. EdgeGuard is an AI-driven, edge-computing predictive maintenance system designed to continuously monitor transformer health and forecast failures before catastrophic damage occurs. The system acts as a retrofittable “Digital Doctor” for distribution transformers by combining low-cost industrial sensors, an ESP32 microcontroller, local intelligence, machine learning-based risk prediction, autonomous relay control, and a real-time web dashboard. The proposed system monitors six major transformer health indicators: temperature, humidity, vibration, oil level, current, and voltage. These signals are normalized and processed through a Multi-Layer Perceptron neural network to classify transformer condition and estimate failure risk. If the predicted risk crosses a critical threshold of 80%, EdgeGuard automatically triggers a relay through GPIO 26 to isolate the transformer from the electrical network. The system also supports secure remote control, dashboard monitoring, API-key-based hardware authentication, JWT-based user access, WebSocket live updates, and automatic live-hardware detection. With an estimated deployment cost of approximately ₹3,850, EdgeGuard offers a low-cost alternative to conventional transformer monitoring systems. Its cloud-independent operation and edge-based decision-making make it especially useful for rural and semi-urban distribution grids where connectivity and maintenance resources are limited.
28 July 2026
ANALYZING TOXIC USER BEHAVIOR AND RISK PATTERNS IN ONLINE GAMING PLATFORMS
This study shows that behavioral data alone can't reliably predict gaming toxicity — but a risk-based model combining behavioral and engineered features does a much better job of flagging the small segment of high-risk users driving disproportionate harm.