Back to Projects
Applied Machine Learning · Production Backend

Production Customer Churn API & ML Pipeline

An end-to-end applied machine learning system predicting customer attrition on the Telco dataset (7,043 records). Prioritizes strict data leakage elimination, feature preprocessing, containerized serving, and experiment tracking.

PythonXGBoostFastAPIMLflowDockerRender
View on GitHub

01 / Overview

An end-to-end applied machine learning system predicting customer attrition on the Telco dataset (7,043 records). Prioritizes strict data leakage elimination, feature preprocessing, containerized serving, and experiment tracking.

02 / The Problem

Most machine learning portfolio projects rely on Kaggle notebooks that accidentally include target leakage columns (e.g. Churn Reason, Churn Category, Churn Score) leading to unrealistic 99% accuracy that crashes in real-world deployment.

03 / My Solution & Architecture

Trained an XGBoost gradient boosting classifier using an 80/20 stratified split after explicitly stripping all post-event leakage columns. Served via a containerized FastAPI application with strict Pydantic schema validation, tracked using MLflow, and deployed as a reproducible Docker service on Render.

Key Engineering Decisions & Trade-Offs

Explicit Purging of Post-Event Columns (Target Leakage)

Features recorded only after customer churn occurs (such as Churn Reason) falsely inflate model scores. Dropping them produced a defensible, production-accurate 81% accuracy model.

FastAPI Microservice with Typed Pydantic Schemas

Validating payload types, ranges, and missing fields at the API gateway layer prevents malformed feature vectors from reaching the trained XGBoost booster.

MLflow Experiment Run Logging

Logging evaluation metrics, hyperparameter iterations, and serialized model binaries ensures full lineage and reproducible deployments.

04 / Technologies Used

PythonXGBoostFastAPIMLflowDockerRender

Every technology in this stack was chosen for direct architectural fitness, verifiable benchmarking ability, and clean maintainability in a production or research setting.

05 / How It Works & Interactive Visualizer

Here is a breakdown of how the system functions in practice:

  • Trained XGBoost classification pipeline with stratified cross-validation.
  • FastAPI inference REST microservice with OpenAPI specification.
  • Containerized Dockerfile for zero-dependency cloud deployment.
  • Comprehensive validation metric reporting (Accuracy, Precision, Recall, F1).
  • Interactive decision boundary simulation for tenure and monthly charge combinations.

Interactive Technical Visualizer

How to interact: Use the controls above to trigger live states, test inputs, and observe system data flow directly in your browser.

06 / Results & Verified Findings

  • Verified performance metrics: 81% accuracy, 77% precision, 68% recall, and 72% F1 score.
  • Transparent disclosure: Calling out the 68% recall rate as an intentional engineering trade-off that requires custom threshold tuning in business settings.
  • Fully containerized, production-ready inference API with zero external notebook dependencies.

07 / What I Learned & Direct Contributions

Key engineering responsibilities and lessons gained during this project:

  • Performed rigorous data cleansing and leakage isolation on 7,043 customer accounts.
  • Engineered end-to-end model pipeline with categorical label encoding and hyperparameter tuning.
  • Constructed production FastAPI REST service with GET /health and POST /predict endpoints.
  • Created Dockerfile and container configuration for deterministic cloud deployment.

08 / Future Improvements

Free-tier Render deployment enters cold sleep after idle periods; SHAP explainability visualizations and automated drift monitoring are planned next steps.

Email copied to clipboard