← Back to Projects
End-to-End Churn Model
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
- Find a customer churn dataset on Kaggle (e.g., Telco Customer Churn).
- Clean the data and split it into training and testing sets.
- Build a
scikit-learnPipeline that handles scaling numerical features and one-hot encoding categorical features. - Train a baseline Logistic Regression model, then train a Random Forest classifier.
- Evaluate both models using a confusion matrix, precision, recall, and F1-score. Pick the best one.
- Export the fitted model and pipeline using
joblib. - Write a minimal FastAPI app that loads the
joblibfile on startup and exposes a/predictendpoint taking user features and returning a churn probability.