← Back to Projects

End-to-End Churn Model

intermediatePhase 02 · Classical MLPythonscikit-learnFastAPI

Train a RandomForest classifier on tabular customer churn data, evaluate with precision/recall, export it, and serve predictions.

What you'll learn

  • Performing Train/Test/Validation splits correctly
  • Training a baseline classifier vs. a more advanced ensemble model
  • Evaluating models using Precision, Recall, and F1-score
  • Saving/Exporting a model and serving predictions over an API

Architecture

Tabular Data (Kaggle)
  → Preprocessing Pipeline (Imputing, Scaling, Encoding)
  → Model Training (scikit-learn RandomForest)
  → Export (Joblib)
  → FastAPI Model Server

Steps

  1. Find a customer churn dataset on Kaggle (e.g., Telco Customer Churn).
  2. Clean the data and split it into training and testing sets.
  3. Build a scikit-learn Pipeline that handles scaling numerical features and one-hot encoding categorical features.
  4. Train a baseline Logistic Regression model, then train a Random Forest classifier.
  5. Evaluate both models using a confusion matrix, precision, recall, and F1-score. Pick the best one.
  6. Export the fitted model and pipeline using joblib.
  7. Write a minimal FastAPI app that loads the joblib file on startup and exposes a /predict endpoint taking user features and returning a churn probability.

← Back to the roadmap