Predict telecom churn from usage data
A telecom operator loses some of its customers, and can try to keep them if it knows in time who is likely to leave. This guide trains a Fione model that gives each customer a probability of leaving (churning). It goes from the download of an open dataset to a curl call of the served model.
Starting Fione from the published images and the general serving steps are in the practical guides overview. This page shows what is particular to this use case.
The business question
In the data used here, about 16% of the customers churned. An operator that knows months ahead which customers are likely to leave can act on it:
- offer a retention deal, such as a discount or a better plan, to the customers most likely to leave;
- spend no discount on customers who would stay anyway;
- look at what the customers likely to leave have in common, such as complaints or how much they call.
The model answers one question per customer: will this customer churn? It returns a yes/no answer and, more usefully, the probability of yes.
Get the data
The data is the Iranian Churn dataset from the UCI Machine Learning Repository:
- Page: https://archive.ics.uci.edu/dataset/563/iranian+churn+dataset
- Creators: the UCI page names none
- DOI: 10.24432/C5JW3Z
- Licence: Creative Commons Attribution 4.0 International (CC BY 4.0)
Attribution (UCI's citation): Iranian Churn [Dataset]. (2020). UCI Machine Learning Repository. https://doi.org/10.24432/C5JW3Z. What we changed: we removed the rows that repeat an earlier row exactly, and set the last 20 of the remaining rows aside to try predictions on (see Prepare the CSV); no value was changed.
In an empty directory, download and unpack it:
curl -LO https://archive.ics.uci.edu/static/public/563/iranian+churn+dataset.zip
unzip iranian+churn+dataset.zipThe zip holds one file, Customer Churn.csv (about 130 KB; the name has a space in it): comma-separated, with a header row, plain ASCII text (so also valid UTF-8). It has 3,150 rows and 14 columns, all numbers, and no empty cells. According to UCI, the data was collected at random from an Iranian telecom company's database over 12 months, and each row is a customer.
The data
| Column | What it holds |
|---|---|
Call Failure | Number of call failures |
Complains | 1 if the customer complained, 0 if not |
Subscription Length | Total months of subscription |
Charge Amount | Charge level, from 0 (lowest) upwards |
Seconds of Use | Total seconds of calls |
Frequency of use | Total number of calls |
Frequency of SMS | Total number of text messages |
Distinct Called Numbers | Number of distinct numbers called |
Age Group | Age group, from 1 (youngest) to 5 (oldest) |
Tariff Plan | 1 pay as you go, 2 contract |
Status | 1 active, 2 non-active |
Age | Age, as 15, 25, 30, 45 or 55 (UCI does not describe this column; these are the values in the file) |
Customer Value | "The calculated value of customer" |
Churn | The answer: 1 if the customer churned, 0 if not |
Three column names have two spaces between their words: Call Failure, Subscription Length and Charge Amount. Fione's pages, and the column names in the text and tables of this page, show them with one space, but the model expects the names as they are in the file. Copy them from the header in the sample below or from /model when you call the API (see Serve it as an API).
The file differs from UCI's page in a few details: UCI counts 13 columns (the file has 13 inputs plus Churn), lists an "Anonymous Customer ID" that is not in the file, and describes Charge Amount as 0 to 9, while 7 rows have 10. Age is the same information as Age Group: each group has exactly one age (group 1 is 15, 2 is 25, 3 is 30, 4 is 45, 5 is 55).
UCI also says when the values were taken: "All of the attributes except for attribute churn is the aggregated data of the first 9 months. The churn labels are the state of the customers at the end of 12 months. The three months is the designated planning gap." So the model predicts, from nine months of a customer's data, whether the customer will have left three months later. That gap is the time the operator has to act.
Churn is 1 for 495 of the 3,150 rows (15.7%). Three ordinary rows, a customer who stayed, one who churned and one who stayed on a contract:
Call Failure,Complains,Subscription Length,Charge Amount,Seconds of Use,Frequency of use,Frequency of SMS,Distinct Called Numbers,Age Group,Tariff Plan,Status,Age,Customer Value,Churn
8,0,38,0,4370,71,5,17,3,1,1,30,197.64,0
2,1,10,1,1082,14,0,9,3,1,1,30,43.84,1
15,0,18,1,5987,136,67,44,2,2,1,25,577.035,0Before training, look at three things.
First, repeated rows. 300 of the 3,150 rows repeat an earlier row in every column, often in runs: for example, data rows 1 to 10 appear again as rows 951 to 960 and as rows 1,001 to 1,010. UCI does not mention them. Two customers are unlikely to match in every column, including the exact seconds of calls and the customer value, so we read them as copies of the same customer, not as other customers, and remove them. If they stay, a copy can land among the rows Fione learns from and its twin among the rows it checks the models on, and the figures would then look better than they are for new customers. Without the copies, 2,850 rows remain, and 446 of them (15.6%) churned.
Many of the remaining rows also have a near copy. Take rows 6 and 15 of the new-customers.csv made below: they have the same Complains, Distinct Called Numbers, Age Group, Tariff Plan, Status, Age and Churn, and row 15 has exactly 6 more call failures, 1 more month of subscription, 1 more charge level, 710 more seconds of calls, 11 more calls and 25 more text messages. The same shift links rows 7 and 16 and rows 8 and 17. In our count, 1,370 of the 2,850 rows have the same values as another row in those six columns and differ from it in call failures, months, charge level, seconds and calls by a shift that at least 40 pairs of rows among the 2,850 share. UCI does not mention them, and we cannot tell what they are, so we leave them in. Keep them in mind when you read the results: a row the models are checked on can have a near copy among the rows they learn from. In our check, a near copy has the same Churn no more often than other rows with the same values in those six columns (82% of the pairs against 88%), so we expect them to raise the figures little; that is our reading, not something we measured on new customers.
Second, Status. It is close to the answer: of the customers marked non-active (2), 48% churned; of the active ones (1), 6% (counted on the 2,850 rows). Whether to keep a column like this depends on two things: is the value known at the moment you predict, and is it computed from the outcome you are predicting? UCI gives no more than "1: active, 2: non-active", but by its statement above every column except Churn comes from the first nine months, before the outcome. On that statement we keep it. Before you do the same with your own data, check that the status you feed the model is the one at the time you predict, and that a customer who has given notice or already left is not marked non-active because of that. If you cannot be sure, leave Status out and expect results like our second run in Read the results.
Third, Customer Value. UCI calls it "the calculated value of customer" and does not say how it is calculated. In our check, it can be worked out almost exactly from the other columns (a straight-line fit on them explains 98% of its variation), and adding Churn to that fit does not make it any closer. We read this as a value computed from the other first-nine-month figures, not from the outcome, and keep it. If your own customer value is computed with information from after the time you predict, leave it out.
Prepare the CSV
The file is already a CSV that Fione reads. Two steps are needed: remove the repeated rows, and keep a few customers apart, so that you can later predict rows the model never learned from. This command keeps the first of each set of identical rows, in file order, writes the last 20 of them to new-customers.csv and the other 2,830 to train.csv, both with the header:
python3 - <<'PY'
lines = open("Customer Churn.csv", "rb").read().splitlines(keepends=True)
header, seen, rows = lines[0], set(), []
for line in lines[1:]:
if line not in seen:
seen.add(line)
rows.append(line)
open("train.csv", "wb").write(header + b"".join(rows[:-20]))
open("new-customers.csv", "wb").write(header + b"".join(rows[-20:]))
print(len(lines) - 1, "rows,", len(rows), "after removing copies")
PYIt prints 3150 rows, 2850 after removing copies. Of the 20 customers set aside, 5 churned. Remove the copies before setting rows aside: in the original file, 19 of the last 20 rows also appear earlier, so the model would already have learned from them. The near copies stay: 11 of the 20 customers set aside have one in train.csv, so they are not entirely new to the model.
Train the model
- On Projects, create a project (we named it
telecom-churn) and open it. - Press Upload training data, choose
train.csvand press Upload and analyze. Data analysis shows 2,830 rows, 14 columns and 0% empty cells. - Under What do you want to predict?, choose
Churn. Fione sees two values in it and suggests Classification, although they are written as numbers. - Under Which columns should the model learn from?, all 13 other columns are checked; Fione unchecks none of them here, not even
Age, which repeatsAge Group. Leave them as they are. Fione readsComplains,Age Group,Tariff Plan,StatusandAgeas Category and the others as Number. - Keep Classification under Prediction type.
- Under Maximum run time, choose 10 min (the default is 3 min; a longer run can find better models).
- Press Run.

When training ends, the page moves on to the Prediction summary.
Read the results

In our run:
- Rating: 5 out of 5. "On rows it did not learn from, the model was right about 97% of the time. Always guessing the most common answer would be right 84% of the time."
- Guide: "Excellent! The model predicts very well. Let's put it to work on new data."
- About this model: a blend of 6 models, 186 models tried, training time 6:13.
- Most useful inputs:
Status13%,Seconds of Use12%,Frequency of use11%,Subscription Length11%,Call Failure11%.
Start with the class balance: 84% of the customers stayed, so a "model" that always says "stays" is right 84% of the time and finds no churner at all. The rating measures how far the model gets from that guess towards a perfect score. Unrounded, the model's Accuracy (on the Metrics tab, below) is 0.969 and always guessing "stays" is right for 84.4% of the training rows, so the model covers (0.969 − 0.844) / (1 − 0.844) ≈ 0.80 of that distance. That is just at 0.8, where 5 stars begin (How is the rating calculated? on the summary gives the formula and the bands). For an operator, what counts is whether the model finds the customers who will leave, and how often it is right when it says "will leave".
Press Open advanced details and open the Metrics tab. It shows the figures measured on rows the models did not learn from. In our run:
- AUC 0.99 (0.5 is guessing, 1 is perfect): take one customer who churned and one who stayed, and the model gives the one who churned the higher probability about 99% of the time.
- Top-10% lift 6.3: the 10% of customers the model rates most likely to leave churned 6.3 times as often as the average customer: about 99% of them, against 16% of all customers.
- Confusion matrix: of the 441 customers who churned, the model said
1for 385 (87%) and missed 56. Of the 2,389 who stayed, it said1for 32 (1%). Of the 417 customers it called1, 385 (92%) did churn (Precision 0.923).
These figures come from rows of the same data, set aside in turn while the models learn. Because near copies stay in the data, a row the models are checked on can have a twin among the rows they learn from, so the figures may be higher than they would be for new customers. They tell you how well the model works on customers like these; before an operator relies on it, it should also be checked on later customers of its own.
The 0/1 answer is the more likely of the two (the model's Choosing the predicted class setting is Most likely class). An operator does not have to use that cut-off. With a budget for a fixed number of offers, it can rank customers by the probability and make offers from the top of the list down; or it can pick its own cut-off: lower to reach more of the customers who would leave at the cost of more offers to customers who would stay, higher to make fewer, surer offers.
Most useful inputs is captioned "The columns that moved the predictions most, as a share of all the columns' effect." Fione works this out on its own shortly after training (about 15 seconds after it in our run), by explaining the model's predictions on rows of the training data. In our run the effect is spread over several columns: whether the customer is active (Status), how much they call (Seconds of Use, Frequency of use), how long they have subscribed (Subscription Length) and how many of their calls failed (Call Failure) each account for 11–13%. Until that explanation is done, the summary shows a different list instead, captioned "The columns the model relied on most, as a share of all it used." and based on the training's own measure; that list stays on the Importance tab (in our run Seconds of Use, Frequency of use and Subscription Length 18% each, Status 15%, Complains 13%).
To see how much the model depends on Status, we trained a second model in the same way without it: it got 4 out of 5, right about 96% of the time (AUC 0.99, Top-10% lift 6.2). Of the 441 customers who churned it found 375 (85%), against 385 with Status, and it said 1 for 39 customers who stayed, against 32. Its rating score, (0.963 − 0.844) / (1 − 0.844) ≈ 0.76, falls just below the 0.8 mark, hence one star less. So the model loses little without Status: the other columns carry most of what it can tell.
Make predictions
Predict the 20 customers you set aside:
- On the Prediction summary, press Make predictions.
- Choose
new-customers.csvand press Upload. Fione says that "new-customers" (20 rows) has every column the model needs, and marksChurnas Not used by the model. Keep it checked under Columns in the result: it is copied next to the predictions, so you can compare them with what happened. - Press Predict. Predictions shows 20 rows × 17 columns and Download predict_new-customers.csv.
predict is the answer, and p_1 the probability of churn. Five of the 20 rows in our run:
| Row | Complains | Status | p_1 | predict | Churn (what happened) |
|---|---|---|---|---|---|
| 1 | 0 | 2 | 0.15 | 0 | 0 |
| 2 | 0 | 2 | 0.12 | 0 | 0 |
| 10 | 1 | 1 | 0.9997 | 1 | 1 |
| 13 | 1 | 2 | 0.998 | 1 | 1 |
| 14 | 0 | 2 | 0.90 | 1 | 1 |
All 5 customers who churned got a p_1 of 0.90 or more, and the other 15 got less than 0.16, so every predict matches what happened. 11 of these 20 rows have a near copy in train.csv, one of them among the 5 who churned, so this may be an easier test than new customers would be. Under the table, Why these predictions shows, for the first 5 rows, the columns that moved each prediction most. For row 1 it starts from an average prediction of 12.1%; Distinct Called Numbers (value 9) lowers the chance by 11.3 points and Seconds of Use (value 295) raises it by 9.0 points, ending at 15.5%.
Serve it as an API
Under Serve it from your own system, press Download the serving bundle. Unpack it into a directory of its own and run the command shown on the card there, as in the overview. Use the name of your file; for our model:
unzip fione-serving-Churn-model-2026-11-28-06-57-10.zip -d fione-serving-Churn-model-2026-11-28-06-57-10
cd fione-serving-Churn-model-2026-11-28-06-57-10
docker run --rm -p 8081:8080 -v "$PWD/model:/model:ro" ghcr.io/codelibs/fione-serving:snapshotIn another terminal, ask which columns the model expects:
curl -s localhost:8081/model{"names":["Call Failure","Complains","Subscription Length","Charge Amount","Seconds of Use","Frequency of use","Frequency of SMS","Distinct Called Numbers","Age Group","Tariff Plan","Status","Age","Customer Value","Churn"],
"domains":[null,null,null,null,null,null,null,null,null,null,null,null,null,[0,1]],
"responseColumn":"Churn","category":"Binomial","nclasses":2,"nfeatures":13, ...}Send rows 1 and 10 of new-customers.csv, one customer who stayed and one who churned:
curl -s -X POST localhost:8081/invocations -H 'Content-Type: application/json' -d '{"instances":[{"Call Failure":10,"Complains":0,"Subscription Length":28,"Charge Amount":0,"Seconds of Use":295,"Frequency of use":20,"Frequency of SMS":0,"Distinct Called Numbers":9,"Age Group":3,"Tariff Plan":1,"Status":2,"Age":30,"Customer Value":12.6},{"Call Failure":2,"Complains":1,"Subscription Length":10,"Charge Amount":1,"Seconds of Use":1082,"Frequency of use":14,"Frequency of SMS":0,"Distinct Called Numbers":9,"Age Group":3,"Tariff Plan":1,"Status":1,"Age":30,"Customer Value":43.84}]}'{"predictions":[{"label":0,"index":0,"class_probabilities":[0.8453554332457349,0.154644566754265]},{"label":1,"index":1,"class_probabilities":[0.000346828490413189,0.9996531715095869]}]}class_probabilities follow the classes of Churn in domains, 0 then 1, so the second number is the probability of churn: 0.15 and 0.9997, the same as p_1 for these rows under Make predictions. An operator's system would send each customer's figures and use that number to decide whom to offer a deal.
Write the three names with two spaces exactly as in /model. In our run, a request that wrote them with one space got no prediction, only this body, and the HTTP status was still 200, so check the body for exception:
{"predictions":[{"exception":"missing columns: ['Call Failure', 'Subscription Length', 'Charge Amount']"}]}Values sent as strings, such as "0" or "12.6" as in the CSV, gave the same probabilities as numbers.
From an AI tool
AI tools such as Claude and Codex can do the same through Fione's MCP endpoint: upload the CSV, train, read the results and predict. For a few customers, the predict tool takes rows like the two above and returns predict, p_0 and p_1 for each. Called directly over MCP for the model trained above, it returned the same probabilities as the API above (0.15 and 0.9997). How to connect a client and what to ask is in Run the AutoML loop from an AI tool with MCP, and the predict tool in Predicting new rows.