Daniel S. Demoz · Responsible AI in practice All projects  ·  Code

E-commerce churn

A churn dashboard, and an honest look at the data behind it

A Streamlit app for exploring and scoring e-commerce churn. This page explains what it does, which data the hosted version runs on, and what that means for its results.

Working app · demo data Streamlit Planted patterns disclosed Real data not included

What the app does

A Streamlit dashboard in dashboard.py for e-commerce churn.

Explore

Churn rates by tenure, satisfaction, device, payment method and other fields.

Model

Random forest and logistic regression, with accuracy, a confusion matrix and feature importance.

Score one customer

Enter a customer profile and get a churn probability.

Open the Streamlit app (it may take a minute to wake up).

Which data it runs on

The real dataset is not in this repository. The app looks for a file named "E Commerce Dataset.xlsx". When it is missing, the app generates 1,000 demo customers instead. The hosted app runs on that demo data.

Models on the demo data

ModelAccuracyAUC
Always guess "stays"56.7%0.500
Logistic regression56.8%0.573
Random forest58.8%0.631

5-fold cross-validation on the 1,000 generated customers.

The built-in pattern

The generator raises churn for customers with satisfaction 2 or lower, a complaint, or tenure of 6 months or less. 70% of demo customers match.

Churn is 54% for them and 19% for the rest. Any "key churn drivers" the app finds on demo data are these planted rules.

Honest finding: on demo data the models barely beat guessing. The 95.8% accuracy and churn drivers in the earlier README could not be reproduced from this repository, so they were removed.

Before using it on real customers

Data

  • Load real customer records, and say where they came from and under what licence.
  • Define churn from later behaviour, such as no order in the next 90 days.
  • Test on a later time period, the way the model would be used.

Use

  • Check accuracy and false alarms by customer group, such as city tier and gender.
  • Use scores to choose who gets a retention offer, not to treat anyone worse.
  • Measure the offer with a holdout group, so the impact is known, not assumed.

Reliable AI checklist

The six questions of the Reliable AI Adoption Framework, answered for this project.

Business problem

Spot customers likely to stop buying, so a retention team can reach them first.

Data readiness

The real dataset is not included. The hosted app runs on generated demo data with planted patterns.

Governance and risk

Scores from demo data must never be presented as customer insight. The app now says which data it is using.

Technology and tools

Random forest and logistic regression in Streamlit. Simple and inspectable.

People and adoption

A retention lead reviews the list and chooses the offer. The model only ranks.

Outcomes and monitoring

On real data, compare predicted and actual churn each quarter, by customer group.