How muthukamalan/customer-churn-prediction works
Purpose and Entry Points
Local, end-to-end MLOps project for telecom churn classification: prepare Excel source data, ingest/version it, train and tune scikit-learn models, track artifacts, and serve predictions. Primary executable entry points are scripts/prep_db_ingestion.py, src/train/train.py, src/hparams/hparams.py, and src/inference/app.py.
Data Preparation and Versioning
Raw telecom Excel exports are expected under data/raw/. The preparation script transforms them into a database-ingestible processed dataset; PostgreSQL subsequently hosts the mlchurn.customer_churn table. DVC tracks the dataset imported from that table, separating reproducible data state from source code.
• scripts/prep_db_ingestion.py
• customer_churn.csv.dvc
• data/raw/.gitkeep
Configuration-Driven ML Execution
Hydra composes runtime configuration for data, paths, model selection, training, and MLflow settings. The default training composition is rooted in configs/train.yaml; model-specific YAML files select one of logistic regression, decision tree, gradient boosting, k-nearest neighbors, or random forest. This boundary lets commands override model and run settings without modifying Python.
• configs/train.yaml
• configs/config.yaml
• configs/model/default.yaml
Feature Engineering and Training
Training loads the versioned churn data, applies shared feature transformation, fits the selected scikit-learn estimator, and records the run. Feature preparation is isolated from orchestration so training and inference can preserve compatible input expectations.
• src/featureeng/feateng.py
• src/train/train.py
• configs/data/default.yaml
Hyperparameter Optimization
A dedicated Hydra multirun/Optuna workflow searches model parameters, optimizing F1 score according to the README. Search spaces are model-specific and independent of ordinary training configuration; results are expected to be tracked as MLflow experiments and used to select a later training run.
• src/hparams/hparams.py
• configs/hparams/decision_tree_hparam.yaml
• configs/hparams/random_forest_hparam.yaml
Experiment, Artifact, and Service Infrastructure
Docker Compose provides local service discovery and infrastructure: PostgreSQL for operational data and MLflow metadata, MLflow for run/model tracking, and MinIO/S3-compatible object storage for artifacts and model weights. Container initialization and service wiring are defined outside application modules.
• compose.local.yaml
• postgres/init-db.sh
• postgres/servers.json
Model Serving and Observability
The inference boundary is a FastAPI application that reads MLflow/MinIO connection settings from environment variables, loads a named model, exposes health checks, and accepts prediction payloads. Prometheus scrapes container metrics; Grafana visualizes Prometheus and PostgreSQL data. The inference image is separately buildable, enabling deployment apart from training.
• src/inference/app.py
• src/inference/Dockerfile
• prometheus/prometheus.yaml
• grafana/connections.md
Main entry points: compose.local.yaml Local Compose stack · train.py Model training · hparams.py Optuna hyperparameter search · feateng.py Feature transformation
Components 18
Data pipeline
- Raw Excel exports
data/raw/.gitkeep - Preparation job · Transforms source exports into ingestible churn data.
scripts/prep_db_ingestion.py - PostgreSQL churn table · Hosts mlchurn.customer_churn.
- Versioned churn dataset · Reproducible dataset state imported from PostgreSQL.
customer_churn.csv.dvc
ML workflow
- Training configuration · Composes data, paths, model, training, and MLflow settings.
configs/train.yaml - Model selection config · Selects a scikit-learn estimator.
configs/model/default.yaml - Feature transformation · Keeps training and prediction input expectations compatible.
src/featureeng/feateng.py - Model training · Fits the configured estimator and records a run.
src/train/train.py - Optuna hyperparameter search · Hydra multirun optimizes F1 with model-specific search spaces.
src/hparams/hparams.py - Hyperparameter search spaces
configs/hparams/decision_tree_hparam.yaml
Local platform
- Local Compose stack · Wires PostgreSQL, MLflow, MinIO, and monitoring services.
compose.local.yaml - Database initialization
postgres/init-db.sh - MLflow tracking · Stores run metadata and registered model references.
- MinIO artifact storage · Stores MLflow artifacts and model weights.
Serving & observability
- Prediction API · Loads a named tracked model and serves health and prediction endpoints.
src/inference/app.py - Inference container image · Separately deployable serving image.
src/inference/Dockerfile - Prometheus · Scrapes container metrics.
prometheus/prometheus.yaml - Grafana dashboards · Visualizes Prometheus and PostgreSQL data.
grafana/connections.md
Connections 24
- Raw Excel exports → Preparation job: prepare
- Preparation job → PostgreSQL churn table: ingest
- Database initialization → PostgreSQL churn table: initialize
- PostgreSQL churn table → Versioned churn dataset: import and version
- Training configuration → Model selection config: selects
- Training configuration → Model training: configures
- Versioned churn dataset → Model training: load
- Feature transformation → Model training: transform
- Hyperparameter search spaces → Optuna hyperparameter search: defines search
- Versioned churn dataset → Optuna hyperparameter search: evaluate data
- Feature transformation → Optuna hyperparameter search: transform
- Optuna hyperparameter search → MLflow tracking: track trials
- Model training → MLflow tracking: track run and model
- MLflow tracking → MinIO artifact storage: store artifacts
- MLflow tracking → Prediction API: load named model
- Feature transformation → Prediction API: compatible inputs
- Inference container image → Prediction API: packages
- Local Compose stack → PostgreSQL churn table: runs
- Local Compose stack → MLflow tracking: runs
- Local Compose stack → MinIO artifact storage: runs
- Local Compose stack → Prometheus: runs
- Local Compose stack → Grafana dashboards: runs
- Prometheus → Grafana dashboards: metrics source
- PostgreSQL churn table → Grafana dashboards: data source