A machine learning web application built with FastAPI, Scikit-Learn, Jinja2, and Docker. This app predicts a student's math score based on various demographic factors and academic performance metrics.
--
├── artifacts/
│ ├── model.pkl # Trained ML model
│ └── preprocessor.pkl # Fitted Scikit-Learn ColumnTransformer
├── templates/
│ └── index.html # Jinja2 HTML template with custom CSS
├── train.py # Script to train model and export artifacts
├── main.py # FastAPI server and endpoints
├── requirements.txt # Python dependencies
├── Dockerfile # Docker container configuration
└── .dockerignore # Files ignored by Docker build
- Machine Learning Pipeline: Uses
ColumnTransformerwithOneHotEncoderandStandardScalerpaired withLinearRegression. - FastAPI Backend: Lightweight asynchronous Python web framework handling web forms (
python-multipart). - Clean UI: Responsive, modern CSS form rendered with Jinja2 templates.
- Docker Ready: Includes a lightweight
python:3.11-slimcontainer build configuration.
git clone <your-repository-url>
cd <repository-folder-name>
# On Linux/macOS
python3 -m venv .venv
source .venv/bin/activate
# On Windows
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
Ensure stud.csv is in the root directory, then run:
python train.py
This will generate the required model.pkl and preprocessor.pkl files inside the artifacts/ folder.
uvicorn main:app --reload
Open your browser and visit:
👉 [http://127.0.0.1:8000](http://127.0.0.1:8000)
docker build -t student-performance-app .
docker run -p 8000:8000 student-performance-app
Access the application at http://localhost:8000.
To push and deploy this application on AWS:
- Push to Amazon ECR:
aws ecr get-login-password --region <your-region> | docker login --username AWS --password-stdin <your-account-id>.dkr.ecr.<your-region>.amazonaws.com
docker tag student-performance-app:latest <your-account-id>.dkr.ecr.<your-region>.amazonaws.com/student-performance-app:latest
docker push <your-account-id>.dkr.ecr.<your-region>.amazonaws.com/student-performance-app:latest
- Deploy Container: Launch via AWS App Runner or AWS ECS (Fargate) pointing directly to the image hosted in Amazon ECR.