Telecommunications · Intermediate
Find out why customers leave a telecom operator and build a simple model that flags who is likely to leave next.
data/ folder of the Python Lab.Simu Connect is a fictional telecom operator that sells phone lines, home internet and streaming add-ons on monthly and longer contracts. More customers are leaving every month, and the retention team's answer so far has been a discount for everyone, which is expensive and mostly goes to people who were going to stay anyway. The Head of Customer Retention wants to know why customers leave and which current customers are most likely to leave next, so offers go to the right people. You have one CSV with 7,043 customers, their services, contract, charges and whether they left last month.
Your role
Data Scientist, Customer Retention team, Simu Connect
Retention money is spread across all customers instead of the ones at risk. Simu Connect needs to know which customer groups leave most and a model that ranks customers by risk, so a limited budget reaches the people it can actually keep.
Load telco-customers.csv, check every column's type and convert total_charges to a number. Look at the customers whose total_charges was blank and decide what value makes sense for them. Add a churned column that is 1 for Yes and 0 for No.
Calculate the overall churn rate, then the churn rate by contract type, by tenure band (0-12, 13-24, 25-48 and 49-72 months) and by internet service. Make a labelled bar chart for each.
One CSV file, telco-customers.csv: 7,043 rows and 21 columns (about 950 KB). One row is one customer. The columns describe the customer (gender, senior citizen, partner, dependents), how long they have been a customer (tenure_months), the services they use (phone, multiple lines, internet type and six add-ons), their contract and billing (contract length, paperless billing, payment method, monthly and total charges) and churn: Yes if they left within the last month, No if they stayed. Charges are in US dollars, as in the original file. There is one snapshot only, with no history of calls or data use. Source: IBM's Telco Customer Churn sample dataset (GitHub repository IBM/telco-customer-churn-on-icp4d), licence Apache 2.0, downloaded 24 October 2026. The customers are fictional: IBM created the file to look like a real operator's customer table. What we changed: column names only, renamed to snake_case (for example customerID became customer_id and tenure became tenure_months). Left for you to clean: total_charges is stored as text because a few cells are blank.
telco_churn_customers7,043 customers with demographics, tenure, services, contract, charges in US dollars and whether they churned, from IBM's Telco Customer Churn sample (Apache 2.0). · 7,043 rows
11 exercises worth 170 points. Your code runs in the Python Lab against this project’s data and is marked automatically.
Compare the average monthly charges of customers who left and customers who stayed, then run a t-test to check whether the difference is bigger than chance.
Turn the text columns into numbers with one-hot encoding, split the data 80/20 with stratify, and train a logistic regression and a decision tree with max_depth=4. Measure accuracy and ROC-AUC on the test set and compare with the baseline of predicting that nobody leaves.
Use the logistic regression's probabilities to put each test customer into a low, medium or high risk band, and check the actual churn rate in each band. Write your note for the Head of Customer Retention.
| Column | Type | Description | Example |
|---|---|---|---|
customer_id | text | Unique customer ID. | 7590-VHVEG |
gender | text | Female or Male. | Female |
senior_citizen | integer | 1 if the customer is a senior citizen, otherwise 0. | 0 |
partner | text | Yes if the customer has a partner. | Yes |
dependents | text | Yes if the customer has dependants. | No |
tenure_months | integer | Number of months the customer has been with the operator. | 1 |
phone_service | text | Yes if the customer has a phone line. | No |
multiple_lines | text | Yes, No, or No phone service. | No phone service |
internet_service | text | Type of home internet: DSL, Fiber optic, or No. | DSL |
online_security | text | Add-on: Yes, No, or No internet service. | No |
online_backup | text | Add-on: Yes, No, or No internet service. | Yes |
device_protection | text | Add-on: Yes, No, or No internet service. | No |
tech_support | text | Add-on: Yes, No, or No internet service. | No |
streaming_tv | text | Add-on: Yes, No, or No internet service. | No |
streaming_movies | text | Add-on: Yes, No, or No internet service. | No |
contract | text | Month-to-month, One year, or Two year. | Month-to-month |
paperless_billing | text | Yes if bills are sent electronically. | Yes |
payment_method | text | Electronic check, Mailed check, Bank transfer (automatic) or Credit card (automatic). | Electronic check |
monthly_charges | decimal | Current monthly bill, US dollars. | 29.85 |
total_charges | text (numeric) | Total billed so far, US dollars. Stored as text because a few cells are blank; convert it to a number. | 29.85 |
churn | text | Yes if the customer left within the last month, otherwise No. This is what you predict. | No |
The exercises are marked automatically. The notebook and note are marked on whether cleaning choices are explained, whether models are judged on the test set against a sensible baseline, and whether the recommendations follow from the results and are honest about what a model built on one snapshot cannot tell you.
Recommended tools
Skills covered