Let's stop and think about this for a second
Customer Churn Prediction is one of the most common classification use cases in business — using a customer's behavior data (usage frequency, support ticket count, contract length) to predict whether they're likely to cancel their subscription in the coming weeks, so the business team can proactively send a retention offer to high-risk customers. Class imbalance (churned customers being far fewer than non-churned ones, as is typical in the real world) shows up in this project, which means you'll be putting the Intermediate chapter's Precision/Recall/F1 concepts directly to use.
Let's connect it to a real scenario
Take a customer dataset (usage_frequency, support_tickets, contract_length, churned) and train both a Logistic Regression and a Random Forest Classifier, compare Precision/Recall/F1 with `classification_report()`, then check the Random Forest's `feature_importances_` and write up a short report to the business team on which factors best predict churn.
Let's look at it together
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)
predictions = model.predict(X_test)
print(classification_report(y_test, predictions))
# Which features matter most for predicting churn?
importances = sorted(zip(X.columns, model.feature_importances_), key=lambda x: -x[1])
for feature, importance in importances:
print(f"{feature}: {importance:.2f}") precision recall f1-score
0 0.91 0.95 0.93
1 0.78 0.65 0.71
support_tickets: 0.42
usage_frequency: 0.35
contract_length: 0.23Try it in 5 minutes
Create your own customer churn sample dataset, run it through the full classification pipeline, then look at the `feature_importances_` results and write a one-paragraph insight for the business team.
One thing to watch out for
When using customer data for an ML model, you need to follow privacy/data protection regulations (e.g. GDPR) — using real customer data for model training without authorization or consent can create legal problems.