How ayushai14/churn_prediction_ibm works
This repository is an end-to-end machine learning project for churn prediction, organized around a training pipeline, model evaluation, and two inference paths: an API service and a batch predictor.
The codebase is split into a few clear layers:
• src/data: data ingestion and preprocessing
• src/models: training, evaluation, and prediction logic
• src/pipelines: orchestration of the ML workflow
• mlops/serving: deployment/runtime entrypoints for online and batch inference
• config: runtime and model parameters
• tests: unit and integration coverage
• .github/workflows, docker, dvc.yaml, mlflow: automation, packaging, and experiment/data tracking
Data flow starts in src/data/ingest.py, which likely loads the churn dataset, and src/data/preprocess.py, which transforms it into model-ready features. Those steps are the boundary between raw data handling and the modeling layer.
Model lifecycle is handled in src/models/train.py, evaluate.py, and predict.py. Training builds the classifier, evaluation measures performance, and prediction is reused by both the pipeline and serving code. This separation suggests the repo treats inference as a thin wrapper around shared model logic rather than duplicating logic in the service layer.
src/pipelines/pipeline.py is the orchestration boundary for the main ML workflow. It likely coordinates ingestion, preprocessing, training, and evaluation in one repeatable run, with shared parameters coming from config/config.yaml and config/model_params.yaml.
The project uses DVC for reproducible data/model pipelines. dvc.yaml, dvc.lock, and .dvc/ indicate dataset or artifact versioning and pipeline reproducibility are part of the architecture, so model outputs are expected to be tied to specific data and code versions.
Experiment and run tracking are supported by MLflow under mlops/tracking/mlflow. That makes the training side observable: metrics, parameters, and artifacts can be recorded independently of the serving runtime.
Serving is split into two modes under mlops/serving:
• api/app.py for online requests, likely exposed through a containerized API
• batch/batch_predict.py for offline scoring over a dataset or file
This is a key architectural boundary: one path serves low-latency predictions, the other handles scheduled or bulk prediction jobs.
Containerization is handled in docker/, including a dedicated API Dockerfile and a compose file. That suggests the API is packaged separately from the training environment, with an emphasis on reproducible local and deployment runs.
CI/CD is defined in GitHub Actions workflows for CI, staging, and production. The repo is therefore set up not just for experimentation but for promotion of model/service changes through automated pipelines.
Tests are organized by scope:
• unit tests for preprocessing and model behavior
• integration tests for the API
This shows the architecture is expected to keep the transformation logic stable and the serving contract verified.
notebooks/ and Progress.txt appear to be exploratory and project-tracking artifacts rather than production runtime components. They likely support experimentation and documentation but are not part of the operational path.
Overall, the important architectural boundaries are:
1. raw data vs. transformed features
2. training/evaluation vs. inference
3. offline batch scoring vs. online API serving
4. code execution vs. tracked artifacts/configuration via DVC and MLflow
Main entry points: train.py Train · pipeline.py Pipeline · app.py API App · batch_predict.py Batch Jobs
Components 17
Core ML
Data preparation, training, evaluation, and pipeline orchestration.
- Main · Repository entrypoint for running the churn workflow.
main.py - Pipeline · Coordinates the end-to-end ML workflow.
src/pipelines/pipeline.py - Ingest · Loads the churn dataset from source data.
src/data/ingest.py - Preprocess · Transforms raw data into model-ready features.
src/data/preprocess.py - Train · Builds and fits the churn classifier.
src/models/train.py - Evaluate · Measures model performance and compares outputs.
src/models/evaluate.py - Predict · Shared prediction logic reused by pipeline and serving.
src/models/predict.py
Serving
Online API and offline batch prediction entrypoints.
- API App · HTTP inference service for real-time prediction requests.
mlops/serving/api/app.py - Batch Jobs · Bulk scoring entrypoint for scheduled or file-based prediction.
mlops/serving/batch/batch_predict.py
Ops
Configuration, packaging, tracking, and delivery automation.
- Config · Workflow and model parameters consumed across the repo.
config/config.yaml - Model Params · Hyperparameters and model-specific settings.
config/model_params.yaml - DVC · Reproducible data and model pipeline definitions.
dvc.yaml - MLflow · Experiment tracking and artifact logging.
mlops/tracking/mlflow - Docker · Container definitions for reproducible runtime and deployment.
docker/docker-compose.yml - CI/CD · GitHub Actions workflows for integration and deployment.
.github/workflows/ci.yml
Quality
Tests that guard model behavior and API contracts.
- Unit Tests · Validates preprocessing and model behavior.
tests/unit/test_preprocess.py - API Tests · Checks the serving contract through the API.
tests/integration/test_api.py
Connections 22
- Main → Pipeline: runs · Main entrypoint launches the orchestrated workflow.
- Pipeline → Ingest: loads · Pipeline begins by loading raw churn data.
- Ingest → Preprocess: cleans · Raw data is transformed into features.
- Preprocess → Train: features · Prepared features feed model training.
- Train → Evaluate: scores · Trained model is evaluated against validation data.
- Train → Predict: model · Prediction logic consumes the trained model artifact.
- Pipeline → Train: orchestrates · Pipeline coordinates training as a core stage.
- Pipeline → Evaluate: orchestrates · Pipeline coordinates evaluation as a core stage.
- API App → Predict: serves · Online API wraps shared prediction logic.
- Batch Jobs → Predict: uses · Batch scoring reuses the same inference code.
- Pipeline → Config: reads · Workflow parameters are loaded from config.
- Train → Model Params: reads · Training uses model-specific hyperparameters.
- API App → Config: reads · Serving runtime is configured from project settings.
- Batch Jobs → Config: reads · Batch inference uses shared runtime settings.
- DVC → Pipeline: defines · DVC captures the reproducible ML workflow.
- DVC → Train: tracks · Training outputs and dependencies are versioned.
- MLflow → Train: logs · Training records metrics and artifacts.
- MLflow → Evaluate: logs · Evaluation results are tracked for experiments.
- Docker → API App: packages · Container setup builds and runs the API service.
- Docker → Batch Jobs: packages · Container setup supports batch inference runtime.
- CI/CD → Unit Tests: runs · CI validates the core transformation and model logic.
- CI/CD → API Tests: runs · CI validates the serving contract.