How shivammitra/mlproject works
Purpose and Entry Points
A Python end-to-end student-performance ML project: prepare tabular data, train and serialize a model, then serve predictions through a web UI/API. Runtime entry points are the application server at app.py, training orchestration at src/pipeline/train_pipeline.py, and inference orchestration at src/pipeline/predict_pipeline.py.
Training Data and Ingestion
Training begins with source student data, represented by notebook/data/stud.csv. The ingestion component splits and persists raw train/test datasets under artifacts/: src/components/data_ingestion.py, artifacts/train.csv, and artifacts/test.csv. This artifact directory is the central handoff boundary between training stages.
Feature Transformation
src/components/data_transformation.py fits preprocessing over the training split and applies the same transformation to train/test data. Its serialized preprocessor is persisted as artifacts/preprocessor.pkl, separating feature engineering state from model state and ensuring prediction uses training-consistent transformations.
Model Training and Selection
src/components/model_trainer.py consumes transformed datasets, evaluates candidate model behavior, and serializes the selected estimator to artifacts/model.pkl. CatBoost training outputs in catboost_info/ indicate CatBoost is a material model runtime/training dependency; its logs are generated training diagnostics rather than serving inputs.
Pipeline Orchestration
src/pipeline/train_pipeline.py coordinates ingestion, transformation, and training as one batch control flow. Shared concerns—artifact serialization/loading, logging, and project-specific exceptions—are centralized in src/utils.py, src/logger.py, and src/exception.py. The expected flow is source CSV → train/test artifacts → fitted preprocessor → trained model artifact.
Prediction Serving Boundary
src/pipeline/predict_pipeline.py loads artifacts/model.pkl and artifacts/preprocessor.pkl, transforms incoming feature records, and returns model predictions. app.py exposes this capability through the HTTP application, while templates/index.html and templates/home.html provide browser-facing request/result views. Serving depends on prebuilt artifacts; it does not retrain models per request.
Packaging and Deployment
The application runs on Python with dependencies declared in requirements.txt and package metadata in setup.py. Dockerfile provides a container execution path. AWS Elastic Beanstalk configuration is present at .ebextensions/python.config; the repository also targets EC2 deployment. CI is defined in .github/workflows/main.yaml, supporting automated repository validation/deployment workflows.
Main entry points: train_pipeline.py Training orchestration · data_transformation.py Data transformation · app.py HTTP application · predict_pipeline.py Prediction orchestration
Components 21
Training Pipeline
Batch data preparation and model building.
- Student source CSV
notebook/data/stud.csv - Training orchestration
src/pipeline/train_pipeline.py - Data ingestion · Splits source data into persisted train and test sets.
src/components/data_ingestion.py - Train split
artifacts/train.csv - Test split
artifacts/test.csv - Data transformation · Fits preprocessing on training data and transforms both splits.
src/components/data_transformation.py - Fitted preprocessor
artifacts/preprocessor.pkl - Model trainer · Evaluates candidates and persists the selected estimator.
src/components/model_trainer.py - Trained model
artifacts/model.pkl - CatBoost diagnostics · Generated CatBoost training logs, not serving inputs.
catboost_info/catboost_training.json
Prediction Serving
HTTP prediction interface backed by trained artifacts.
- HTTP application
app.py - Prediction orchestration · Loads trained artifacts and predicts incoming records.
src/pipeline/predict_pipeline.py - Browser views · Input and prediction-result pages.
Packaging & Delivery
Container, deployment, and CI paths.
- Python dependencies
requirements.txt - Package metadata
setup.py - Container build
Dockerfile - Elastic Beanstalk config
.ebextensions/python.config - CI workflow · Automated validation and deployment workflow.
.github/workflows/main.yaml
Other components
- Shared utilities · Artifact serialization/loading and shared support functions.
src/utils.py - Logging
src/logger.py - Project exceptions
src/exception.py
Connections 25
- Student source CSV → Training orchestration: training input
- Training orchestration → Data ingestion: runs
- Data ingestion → Train split: writes
- Data ingestion → Test split: writes
- Training orchestration → Data transformation: runs
- Train split → Data transformation: fit input
- Test split → Data transformation: transform input
- Data transformation → Fitted preprocessor: serializes
- Training orchestration → Model trainer: runs
- Data transformation → Model trainer: transformed data
- Model trainer → Trained model: serializes
- Model trainer → CatBoost diagnostics: generates logs
- Training orchestration → Shared utilities: uses
- Training orchestration → Logging: logs through
- Training orchestration → Project exceptions: uses
- HTTP application → Prediction orchestration: serves requests through
- Browser views → HTTP application: rendered by
- Prediction orchestration → Trained model: loads
- Prediction orchestration → Fitted preprocessor: loads
- Prediction orchestration → Shared utilities: uses artifact loading
- Container build → HTTP application: containerizes
- Python dependencies → HTTP application: runtime dependencies
- Package metadata → HTTP application: packages
- Elastic Beanstalk config → Container build: deployment path
- CI workflow → Container build: builds or deploys