How anandsuraj/churn-prediction-ml-pipeline works
Purpose and Entry Points
This repository implements an end-to-end customer-churn ML data pipeline for the IBM Telco dataset: ingest, validate, clean, engineer/store features, version artifacts, and train a binary classifier. The primary local orchestrator is main_pipeline.py; individual stages live under src/. Scheduled/containerized execution is provided by airflow/dags/churn_prediction_pipeline.py and docker-compose.yml.
Pipeline Orchestration
main_pipeline.py is the sequential control-plane entry point for running the Python pipeline. Airflow provides an alternative DAG-based orchestration boundary, with its own setup/configuration under airflow/setup_airflow.py and airflow/airflow.cfg. The DAG should invoke or coordinate the same stage contracts rather than own duplicate business logic.
Paths: main_pipeline.py, airflow/dags/churn_prediction_pipeline.py, airflow/setup_airflow.py
Ingestion and Raw Data Boundary
Ingestion obtains customer data from CSV and potentially the Hugging Face API, then hands it to raw-data organization/storage. This establishes the immutable source-data boundary before validation or transformations. Raw and exploratory data are rooted under data/eda/raw and data/eda/cleaned, despite README references to broader data/raw and data/cleaned locations.
Paths: src/data_ingestion.py, src/raw_data_storage.py, data/eda/raw
Quality, Preparation, and Transformation
Validation checks data quality/integrity before preparation. Preparation cleans and normalizes records; transformation then produces model-oriented engineered datasets. This is the central data-state progression: raw input → validated/cleaned data → processed training features. Logging is centralized through the utility logger and persisted under logs/.
Paths: src/data_validation.py, src/data_preparation.py, src/data_transformation_storage.py
Feature Store and Persistence
Engineered features are managed separately from transformation logic through a CSV-backed feature-store layer. The committed sample artifact indicates the current local serving/storage contract; the README identifies Redis or PostgreSQL as future production extensions. Database schema initialization supports relational metadata or operational persistence, with SQLite local and PostgreSQL intended for production.
Paths: src/feature_store.py, data/feature_store/churn_features_sample.csv, database/init.sql
Versioning and Reproducibility
DVC is the artifact/versioning boundary for data pipeline outputs and potentially model inputs. Root dvc.yaml/dvc.lock and the nested config/dvc configuration imply tracked, reproducible pipeline stages or alternative DVC project configuration. Remote storage may be configured externally, including cloud/S3 credentials supplied through environment variables.
Paths: src/data_versioning.py, dvc.yaml, config/dvc/dvc.yaml
Model Build and Runtime Infrastructure
Model training consumes the prepared/feature-store data and writes model artifacts under data/models. Python dependencies are defined in requirements.txt. Docker packages the runtime, while Compose likely coordinates the application and Airflow services. Environment configuration is externalized via .env.example; external dependencies include Kaggle source data, Hugging Face API, optional S3/DVC remote, and SQLite/PostgreSQL.
Paths: src/build_model.py, data/models/.gitkeep, Dockerfile
Main entry points: dvc.yaml DVC Pipeline · main_pipeline.py Local Pipeline · churn_prediction_pipeline.py Airflow DAG · feature_store.py Feature Store
Components 20
Orchestration
- Local Pipeline · Sequential control-plane entry point.
main_pipeline.py - Airflow DAG · Alternative scheduled execution boundary.
airflow/dags/churn_prediction_pipeline.py - Airflow Setup
airflow/setup_airflow.py
Data Pipeline
- Customer Data Sources · IBM Telco churn inputs.
- Data Ingestion
src/data_ingestion.py - Raw Data Storage · Immutable source-data boundary.
src/raw_data_storage.py - Data Validation
src/data_validation.py - Data Preparation · Cleans and normalizes records.
src/data_preparation.py - Feature Transformation · Produces model-oriented engineered data.
src/data_transformation_storage.py - Model Training
src/build_model.py
Storage & Reproducibility
- Raw Dataset
data/eda/raw - Feature Store
src/feature_store.py - Churn Features · Current local feature storage contract.
data/feature_store/churn_features_sample.csv - Data Versioning
src/data_versioning.py - DVC Pipeline · Reproducible pipeline-stage definition.
dvc.yaml - Database Schema · Supports local and production persistence.
database/init.sql - Model Artifacts
data/models/.gitkeep
Runtime & Deployment
- Container Runtime
Dockerfile - Service Composition · Coordinates application and Airflow services.
docker-compose.yml - Central Logging · Pipeline stages persist logs under logs/.
Connections 23
- Local Pipeline → Data Ingestion: runs
- Airflow DAG → Local Pipeline: coordinates stages
- Airflow Setup → Airflow DAG: configures
- Customer Data Sources → Data Ingestion: supplies
- Data Ingestion → Raw Data Storage: hands off
- Raw Data Storage → Raw Dataset: writes
- Raw Dataset → Data Validation: input
- Data Validation → Data Preparation: validated data
- Data Preparation → Feature Transformation: cleaned data
- Feature Transformation → Feature Store: engineered features
- Feature Store → Churn Features: persists
- Churn Features → Model Training: training input
- Model Training → Model Artifacts: writes
- Data Versioning → DVC Pipeline: uses
- DVC Pipeline → Raw Dataset: tracks outputs
- DVC Pipeline → Churn Features: tracks outputs
- DVC Pipeline → Model Artifacts: tracks artifacts
- Feature Store → Database Schema: optional relational persistence
- Container Runtime → Local Pipeline: packages
- Service Composition → Container Runtime: runs
- Service Composition → Airflow DAG: hosts scheduling
- Local Pipeline → Central Logging: emits logs
- Airflow DAG → Central Logging: emits logs