Telco Customer Churn Prediction in Python
Analyze the Telco Customer Churn dataset, engineer features, train a random forest classifier, and identify top churn drivers.
What this AI workflow does
This AI Data Analyst workflow loads the Telco Customer Churn CSV dataset and computes the overall churn rate. It encodes categorical variables, checks class balance, and prepares features for modeling. It trains a random forest classifier, reports accuracy and a classification report, and plots the top 10 feature importances to highlight churn drivers.
Who this example is for
This is for data analysts and data scientists who want a reproducible churn modeling example using a standard telco dataset. It helps practitioners practice preprocessing mixed-type tabular data and interpreting a tree-based classifier with feature importance plots.
Expected analysis outcomes
These are the results the AI workflow is expected to generate.
- Dataset loaded with shape (7043, 21) and churn rate around 26.5%
- Categorical encoding completed and class imbalance visualized
- Random forest model trained with accuracy around 0.80 and a classification report
- Top 10 churn drivers plotted, typically including tenure, MonthlyCharges, and TotalCharges
Tools and libraries used
Main Python packages and tooling used to run this AI data analysis task.
- pandas
- numpy
- scikit-learn
- matplotlib
- seaborn
Prompt sequence
This is the exact list of prompts used in this workflow. The same prompt sequence is sent to each model so outputs and scores can be compared fairly.
- 1load the telco churn dataset https://raw.githubusercontent.com/pplonski/datasets-for-start/refs/heads/master/telco-customer-churn/Telco-Customer-Churn.csv and show churn rate
- 2encode categorical variables and show class balance
- 3train a random forest classifier and show accuracy
- 4plot the top 10 most important features for churn prediction
Model Comparison
We compared several LLM models on the same analysis task. The table below shows their scores side by side. You can also open each model run to check the full conversation and notebook results.
| Model Source | Score | Task | Execution | Output | Reasoning | Reliability | Run |
|---|---|---|---|---|---|---|---|
| glm-5.1 | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open glm-5.1 conversation |
| gpt-5.4 | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open gpt-5.4 conversation |
| gpt-oss:120b | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open gpt-oss:120b conversation |
| qwen3-coder-next | 10/10 | 2/2 | 2/2 | 3/3 | 2/2 | 1/1 | Open qwen3-coder-next conversation |
| gemma4:31b | 6/10 | 2/2 | 1/2 | 2/3 | 1/2 | 0/1 | Open gemma4:31b conversation |
| qwen3.5:397b | 6/10 | 2/2 | 1/2 | 2/3 | 1/2 | 0/1 | Open qwen3.5:397b conversation |
How scoring works
Each run is graded on five dimensions:
- Task Completion (0-2): how fully the workflow answered the requested analysis task and completed required steps.
- Execution Correctness (0-2): whether generated code is correct, consistent, and likely runnable without major fixes.
- Output Quality (0-3): how well tables, charts, and results match the expected analytical outcomes.
- Reasoning Quality (0-2): clarity and correctness of interpretation, explanation, and conclusions.
- Reliability (0-1): robustness of the run, including low hallucination risk and stable behavior.
The final score is the sum of these dimensions, so total score = 0-10. Higher values indicate more complete, correct, and reliable notebook results for this workflow.
AI Analysis with glm-5.1
This run uses AI with a step-by-step list of prompts to perform the analysis task Telco Customer Churn Prediction in Python. Below, you can review the full conversation generated with glm-5.1. After the conversation, we show detailed score cards for this run.
Score cards for glm-5.1 for Telco Customer Churn Prediction in Python
Total score: 10/10
Task Completion: 2/2
ExcellentAll four requested steps were completed: dataset loading, churn rate, categorical encoding with class balance, random forest training with accuracy, and top-10 feature importance plot.
Execution Correctness: 2/2
ExcellentThe code is coherent and likely runnable. It successfully produced the reported outputs, including the encoded dataframe shape, accuracy, and feature importance values.
Output Quality: 3/3
ExcellentOutputs match the expected outcomes semantically: churn rate, class balance, model accuracy, and top feature importances are all shown. The feature importance plot and accuracy are present, and the results are plausible.
Reasoning Quality: 2/2
ExcellentThe workflow shows appropriate reasoning about handling `customerID`, converting `TotalCharges`, encoding categoricals, and using stratified train/test split. The explanations are clear and aligned with the task.
Reliability: 1/1
ExcellentThe workflow is reasonably robust, with sensible preprocessing and model evaluation. Minor issues like a seaborn deprecation warning do not affect the core analysis.
Try MLJAR Studio
Run the same type of AI-powered data analysis on your own datasets with conversational notebooks in MLJAR Studio.
Explore More AI Analysis Examples
Discover additional workflows across categories. Each example includes prompts, conversation outputs, and model-level scoring so you can compare approaches and results.