How sahilnegi4444/student-performance-indicator works
1. This repository is a small end-to-end machine learning system for predicting a student’s math score. It has two main runtime paths: an offline training pipeline that produces saved artifacts, and an online Flask prediction app that loads those artifacts to serve predictions.
2. The data source is the student performance CSV dataset stored under artifacts/data.csv and notebook/data/stud.csv. The notebooks in notebook/ were used for EDA and model experimentation, but the production architecture lives in src/ and app.py.
3. The training flow starts in src/pipeline/train_pipeline.py. That pipeline orchestrates the ML lifecycle by calling components for data ingestion, transformation, hyperparameter tuning, and model training. Its purpose is to turn raw tabular data into reusable model artifacts rather than serving requests directly.
4. src/components/data_ingestion.py is responsible for preparing the train/test datasets stored in artifacts/train.csv and artifacts/test.csv. This is the boundary where raw input data becomes the split datasets consumed by downstream training steps.
5. src/components/data_transformation.py builds the preprocessing logic and saves it as artifacts/preprocessor.pkl. This is a key architectural boundary because the same transformation logic used during training must also be reused at inference time to keep feature handling consistent.
6. src/components/model_trainer.py and src/components/hyperparameter_tuning.py handle model selection and fitting. The README indicates Linear Regression was selected as the final model, and the trained estimator is persisted as artifacts/model.pkl. The architecture is therefore a classical scikit-learn training stack with serialized artifacts.
7. Prediction is separated from training in src/pipeline/predict_pipeline.py. The Flask app does not retrain anything; it loads the saved preprocessor and model artifacts, converts form inputs into model-ready features, and returns the predicted score.
8. app.py is the web entry point. It wires Flask routes to the HTML templates in templates/index.html and templates/home.html, giving the system a simple browser-based interface for entering student attributes and displaying the prediction result.
9. src/utils.py, src/logger.py, and src/exception.py provide cross-cutting engineering support. These are not business logic layers; they standardize reusable helpers, logging, and error handling so failures in ingestion, transformation, or inference are easier to trace.
10. The repository is built for both local development and containerized deployment. Dockerfile, .dockerignore, and requirements_docker.txt indicate a production-focused runtime image, and the README notes deployment on Render using Gunicorn. The full requirements.txt is used for local training/dev, while the Docker-specific requirements keep the serving image lighter.
11. The artifacts/ directory is central to the system boundary between offline ML work and online inference. It contains both intermediate datasets and the final persisted model/preprocessor, making deployment possible without rerunning notebooks or retraining on every app start.
12. In diagram terms, the main flow is: dataset and experimentation in notebooks, then training pipeline in src/pipeline/train_pipeline.py, then persisted artifacts in artifacts/, then Flask request handling in app.py, then preprocessing and inference through src/pipeline/predict_pipeline.py, and finally response rendering through the templates.
Main entry points: app.py Flask app · data_ingestion.py Ingestion · predict_pipeline.py Predict pipeline · model_trainer.py Trainer
Components 20
Experimentation
Notebook-based EDA and model exploration
- EDA notebook · Exploratory analysis of student performance data
notebook/EDA_STUDENT_PERFORMANCE.ipynb - Training notebook · Model experimentation and prototyping
notebook/MODEL_TRAINING.ipynb - Stud data · Notebook copy of the student performance dataset
notebook/data/stud.csv
Offline training
Batch pipeline that builds reusable ML artifacts
- Train pipeline · Orchestrates ingestion, transformation, tuning, and training
src/pipeline/train_pipeline.py - Ingestion · Reads raw data and creates train/test splits
src/components/data_ingestion.py - Transform · Builds preprocessing logic and feature pipeline
src/components/data_transformation.py - Tuning · Searches and selects the best model configuration
src/components/hyperparameter_tuning.py - Trainer · Fits the final estimator and persists it
src/components/model_trainer.py
Online serving
Flask app and inference path
- Predict pipeline · Loads artifacts and prepares inference-time features
src/pipeline/predict_pipeline.py - Flask app · HTTP entry point for browser-based prediction
app.py - Home page · Landing page template
templates/home.html - Input form · Student feature entry and result display template
templates/index.html
Shared support
Cross-cutting utilities and persisted artifacts
- Utils · Shared helper functions
src/utils.py - Logger · Logging setup used across the repo
src/logger.py - Exceptions · Centralized error handling and wrapping
src/exception.py - Raw data · Stored source dataset used for training and experimentation
artifacts/data.csv - Train split · Training subset produced by ingestion
artifacts/train.csv - Test split · Test subset produced by ingestion
artifacts/test.csv - Preprocessor · Serialized preprocessing pipeline reused at inference
artifacts/preprocessor.pkl - Model · Serialized trained estimator used for prediction
artifacts/model.pkl
Connections 23
- Stud data → EDA notebook: explore · Notebook dataset used for EDA
- Stud data → Training notebook: prototype · Dataset used in experimentation
- Raw data → Train pipeline: start · Offline training begins from stored data
- Train pipeline → Ingestion: orchestrates · Pipeline invokes ingestion step
- Ingestion → Train split: writes · Creates training split
- Ingestion → Test split: writes · Creates test split
- Train split → Transform: consumes · Transformation uses split training data
- Transform → Preprocessor: persists · Saves fitted preprocessing pipeline
- Train split → Tuning: consumes · Tuning reads prepared training data
- Preprocessor → Trainer: features · Trainer uses shared preprocessing logic
- Tuning → Trainer: selects · Best configuration is handed to training
- Trainer → Model: persists · Saves final trained model
- Flask app → Predict pipeline: calls · Flask route delegates to inference pipeline
- Predict pipeline → Preprocessor: loads · Reuse training-time preprocessing at inference
- Predict pipeline → Model: loads · Loads trained estimator for scoring
- Flask app → Home page: renders · Serves landing page
- Flask app → Input form: renders · Serves input and result page
- Flask app → Logger: uses · App logging support
- Train pipeline → Logger: uses · Training logs and tracing
- Predict pipeline → Exceptions: handles · Inference errors are wrapped consistently
- Ingestion → Exceptions: handles · Ingestion errors are normalized
- Transform → Utils: uses · Transformation reuses shared helpers
- Trainer → Utils: uses · Training reuses common helpers