How maxim-karmanov/binary_classification works
Purpose and entry points
This is a reproducible binary-classification system for bank-marketing response prediction. It supports DVC-managed training, batch/offline prediction, and containerized online inference with monitoring.
Primary entry points:
• DVC orchestration: dvc.yaml, dispatched through src/pipeline.py
• Inference API: main.py
• Async API load generator: scripts/predict_async.py
• Service stack: docker-compose.yml
Data and reproducibility boundary
Raw Kaggle-style train.csv and test.csv are copied into versioned pipeline working data, transformed, split, and consumed by training. DVC tracks stage dependencies, outputs, and parameter changes; artifacts can be pushed to an S3-compatible MinIO remote.
Core paths:
• dvc.yaml
• params.yaml
• src/data/io.py
• src/data/stage.py
• scripts/setup_dvc_remote.ps1
Feature engineering contract
Feature processing is centralized so training and API inference use equivalent transformations on raw records. It normalizes prior-contact semantics, derives categorical/binary/numeric features, and removes the original pdays field. This creates the schema contract between data preparation, model fitting, and /predict.
Core paths:
• src/features/stage.py
• src/pipeline.py
• main.py
Training and model selection
The training stage selects enabled model families and preprocessing paths from parameters. sklearn candidates use ColumnTransformer-style numeric/categorical pipelines; boosting models use native categorical handling. Hyperparameter search uses stratified CV and ROC-AUC, with LightGBM currently the enabled production candidate.
Core paths:
• src/train/model.py
• src/pipeline.py
• params.yaml
Evaluation and artifact promotion
Evaluation compares trained candidates, writes metrics and leaderboard/search outputs, generates batch predictions, and promotes the selected estimator plus metadata as deployable artifacts. The API startup boundary is the persisted joblib model and associated metadata, rather than live training code or DVC internals.
Core paths:
• src/evaluate/stage.py
• src/report/search.py
• src/pipeline.py
Online inference and load flow
main.py runs a FastAPI/Uvicorn batch prediction service. At startup it loads the promoted model; POST /predict receives raw client rows, reapplies feature engineering, and returns id, class prediction, and score. The async client reads test/inference data, batches concurrent requests, schedules them across a duration, and persists API responses for comparison or offline drift analysis.
Core paths:
• main.py
• scripts/predict_async.py
• tests/test_api.py
Runtime infrastructure and observability
Docker Compose provisions the API, MinIO artifact remote, Prometheus, Loki/Promtail, and Grafana. The API exposes Prometheus request, latency, and prediction-class metrics. Promtail filters API container logs to Loki; Grafana is provisioned with both data sources and a prediction-service dashboard.
Core paths:
• docker-compose.yml
• observability/prometheus.yml
• observability/promtail.yml
• observability/grafana/dashboards/prediction-api.json
Analysis boundary
EDA is notebook-based and separate from runtime dependencies. Evidently is available for offline comparison of reference/training-derived data against inference inputs and API outputs, but is not yet a scripted or DVC-managed pipeline stage.
Core paths:
• notebooks/eda.ipynb
• notebooks/data_report.html
• requirements.txt
Main entry points: pipeline.py Pipeline dispatcher · main.py Prediction API · model.py Candidate training · dvc.yaml DVC stages
Components 17
DVC ML Pipeline
Reproducible data-to-model workflow.
- Raw train/test CSV · Kaggle-style source records.
- DVC stages · Tracks dependencies, outputs, and parameter changes.
dvc.yaml - Training parameters · Selects enabled models and preprocessing paths.
params.yaml - Data staging · Copies source CSVs into versioned working data.
src/data/stage.py - Feature engineering · Defines the shared raw-record feature contract.
src/features/stage.py - Candidate training · Runs preprocessing, stratified CV, and ROC-AUC search.
src/train/model.py - Evaluation & promotion · Compares candidates and promotes the selected estimator.
src/evaluate/stage.py - Promoted model & metadata · Persisted joblib estimator and serving metadata.
- MinIO DVC remote · S3-compatible remote for DVC-tracked artifacts.
scripts/setup_dvc_remote.ps1 - Pipeline dispatcher · Executes DVC stage logic.
src/pipeline.py
Online Serving
Containerized prediction and load flow.
- Prediction API · Loads artifacts and serves POST /predict.
main.py - Async load generator · Batches concurrent requests and saves responses.
scripts/predict_async.py - Compose stack · Provisions API, artifact, and observability services.
docker-compose.yml
Observability
Metrics, logs, and dashboards.
- Prometheus · Scrapes request, latency, and prediction metrics.
observability/prometheus.yml - Promtail & Loki · Filters API container logs and stores them.
observability/promtail.yml - Grafana dashboard · Shows prediction-service metrics and logs.
observability/grafana/dashboards/prediction-api.json
Other components
- EDA & offline drift analysis · Separate notebook-based analysis of reference and inference data.
notebooks/eda.ipynb
Connections 23
- DVC stages → Pipeline dispatcher: dispatches
- Training parameters → DVC stages: parameter changes
- Raw train/test CSV → Data staging: copied into working data
- Pipeline dispatcher → Data staging: runs
- Data staging → Feature engineering: staged records
- Pipeline dispatcher → Feature engineering: runs
- Feature engineering → Candidate training: feature schema
- Training parameters → Candidate training: model settings
- Pipeline dispatcher → Candidate training: runs
- Candidate training → Evaluation & promotion: trained candidates
- Pipeline dispatcher → Evaluation & promotion: runs
- Evaluation & promotion → Promoted model & metadata: promotes selected model
- DVC stages → MinIO DVC remote: pushes tracked outputs
- Promoted model & metadata → Prediction API: loaded at startup
- Async load generator → Prediction API: concurrent POST /predict
- Compose stack → Prediction API: runs
- Compose stack → MinIO DVC remote: runs
- Prediction API → Prometheus: exposes metrics
- Prediction API → Promtail & Loki: container logs
- Prometheus → Grafana dashboard: metrics datasource
- Promtail & Loki → Grafana dashboard: logs datasource
- Async load generator → EDA & offline drift analysis: responses for offline comparison
- Raw train/test CSV → EDA & offline drift analysis: reference analysis