← All projects

Main projectPersonal projectAug–Oct 2026, built alongside my internship

Churn Survival

A tool that predicts which customers are likely to leave, and when. It reads customer data and support messages, ranks customers by risk, and explains each ranking in plain language.

In short. Companies get lists of customers who might leave, but a score alone doesn't say why an account is critical. This tool predicts who is likely to leave within 30, 90 and 180 days, ranks customers with fixed rules, and explains each ranking in plain language. The AI only writes the explanations, so it can never change a score.

  • Python
  • lifelines
  • pandas
  • Pydantic
  • FastAPI

Demo video

Watch it work

A recording of the web page: upload a file, run the five steps and read the ranked report. It also shows what happens when there is too little data or the columns are not mapped.

Speed14 chapters
  1. Core flow

  2. Safety and limits

  3. Core flow

  4. Safety and limits

How it flows

Follow a customer file through the five steps

Pick a file from the demo:

What came out

3,832 accounts ranked: 228 critical, 6 high, 245 medium, 3,353 low. CUST-2996 is rank 1 with "cancellation intent detected".

Click any box to see what that step does.

Problem
Customer data is messy, and a risk score is only useful if you can see where it came from.
Approach
Use a method made for "when will it happen" questions, rank customers with fixed rules, and let the AI only help write the explanations.
Result
Tests confirm that the written explanations can never change a customer's score or rank, and that the same data always gives identical results.
Limits
The main tests use made-up data. The demo also runs on a few real datasets from outside sources. They have no support conversations, so their reports show low confidence. Coverage gate is 92%; the last run reached 94%.
Try it
Try the ranking rules ↓

The AI explains. It never decides the numbers. Scores and rankings come from fixed rules, so the same data always gives the same result.

5
steps from raw data to report
0
AI calls when ranking customers
1,546
automated tests passing
30 · 90 · 180
day predictions per customer

01What it does

Companies want to know which customers are about to leave, so they can act in time. This tool takes a customer file and, if you have them, support conversations. It estimates each customer's chance of leaving within 30, 90 and 180 days, ranks everyone by risk, and writes a short explanation for each one.

The key idea: a risk score is only useful if you can see where it came from. So the numbers come from a proven statistics method and fixed rules, and the AI is only allowed to help with wording.

02The five steps

The five steps run one after another in plain Python code. (The project's README mentions LangGraph, but the code does not use it.)

step 1Fixed rules

Read and clean the data

Takes a customer file (CSV or Excel), checks it, and keeps out columns that should not be used.

  • Stops if the data contains dates from the future, which would be cheating.
  • Only approved columns reach the prediction. Other columns are set aside.
  • If it does not recognise the file layout, it stops and asks for a column mapping instead of guessing.
step 2Fixed rules

Predict when customers leave

Uses a method built for "how long until something happens" (survival analysis) to estimate each customer's chance of leaving within 30, 90 and 180 days.

  • It needs enough customers and enough customers who left. If not, it uses a simpler method (Kaplan-Meier) instead.
  • Each time horizon is only reported if there is enough data behind it.
  • The result records which method was used, so you can see when the data was thin.
step 3Fixed rules, AI optional

Read support messages

Looks through support conversations for warning signs, like "I want to cancel", a contract worry, an outage or a billing complaint.

  • By default a simple keyword search does this, with no AI.
  • An AI can be switched on to find the warning signs instead. Then the signs come from the AI.
step 4Fixed rules, no AI

Rank the customers

Combines the prediction and the warning signs into one risk score and a level: low, medium, high or critical.

  • Score = 60% prediction + 40% warning signs, plus a small bonus when both strongly agree.
  • Some warning signs force the level to critical, like a customer clearly saying they want to cancel.
  • Without support messages, the score is just the prediction.
  • If there is no prediction and no messages, the customer is marked "insufficient data".

03Try the ranking rules

This is step four, the ranking. I do not show real customer predictions here, because this explorer uses made-up test data. (The demo video above also runs a few real datasets, which show low confidence because they have no support conversations.) What I can show is the real ranking logic. Move the slider, add warning signs and watch how the level changes.

Your inputs

Result

CRITICAL
Prediction score
0.800
Warning-sign score
0.900
Strongest warning sign
strong
Agreement bonus
+0.05
Final score
0.890
  • from the model Prediction score: in the real tool it comes from the statistics model. Here you set it with the slider.
  • from support messages Warning-sign score: worked out by rules from the warning signs found in support messages.
  • fixed rules Final score, bonus and level: set by fixed rules in code. No AI is involved.

0.6 × 0.800 + 0.4 × 0.900 + 0.05 = 0.890

Critical rules triggered (any one of them makes the level CRITICAL):

  • High quantitative risk plus a strong contract concern
  • High quantitative risk plus a repeated high-severity flag

This runs the project's real ranking rules on the numbers you set. It is not a prediction and not real customer data.

04Why it works this way

Use survival analysis, not a yes/no modelThe question is "when", so the model gives risk over 30, 90 and 180 days.
Rank with fixed rules, no AIScores must be repeatable and easy to explain. Every level comes from a weight, a limit or a named rule.
Say "not enough data"A small group of customers cannot support a prediction, so the tool says so instead of showing a confident-looking number.
Ask before guessing a file layoutIf a file looks new, a person confirms which column is which.

05What the AI may do

By default, nothing: the AI is switched off, support messages are read with a keyword search and explanations come from templates. If you switch it on, it can suggest which column is which in a new file (a person confirms), find warning signs in support messages, and polish the wording of explanations.

Tests check that the ranking never calls an AI and that an explanation can never change a customer's score, level or rank. One thing to remember: if the AI is used to find warning signs, those signs come from the AI, and the ranking then works from them.

Running the same data twice gives exactly the same output in the project's tests (with the same date setting and the AI off).

06The web page

The project comes with a simple web page where you upload data, start a run and read the results. These are its own screenshots.

Web page listing past analysis runs with status, stage, model and number of ranked customers.
The list of past runs. Some finished, some stopped because the data needed checking.
Upload screen with a customer file, support messages and column mapping.
Upload data and start a run.
Screen for confirming which column is which in a new file.
For a new file, a person confirms which column is which.

07What to know

  • The data in the tests is made-up. The demo also runs on a few real datasets from outside sources. They have no support conversations, so their reports show low confidence. This page shows how the ranking rules work, not validated real-world predictions.
  • If the optional AI is switched on to find warning signs, those signs come from the AI. The ranking and explanations still follow fixed rules.
  • Running the same data twice gives identical results on the machine it was built on. Other machines have not been tested.
  • The project is protected by 1,546 automated tests (2 skipped) that cover 94% of the code. On every push, CI (GitHub Actions) checks a 92% coverage minimum, the code style and the types. Tests that need an AI service are marked and never run in CI, so CI needs no AI key.
Get in touch