Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

END-TO-END STUDENT PERFORMANCE PREDICTION SYSTEM USING MACHINE LEARNING AND FASTAPI

Internship Details

  • Company: Codtech IT Solutions Private Limited
  • Name: Abhishek Sharma
  • Intern ID: CTIS9913
  • Domain: Data Science
  • Duration: 6 Weeks

Project Overview

The END-TO-END STUDENT PERFORMANCE PREDICTION SYSTEM is an End-to-End Data Science project developed as part of the Data Science Internship Program at Codtech IT Solutions Private Limited. This project demonstrates the complete machine learning lifecycle, starting from data collection and preprocessing to model training, evaluation, and deployment using FastAPI.

The primary goal of this project is to predict a student's final exam performance based on several academic and personal factors. The model analyzes various features such as study hours, attendance rate, previous academic scores, sleep habits, tutoring sessions, parental education level, internet accessibility, and extracurricular participation to estimate the expected examination score.

In addition to machine learning model development, this project focuses on deploying the trained model as a REST API using FastAPI, allowing users to submit student information and receive predictions in real time. The project showcases how data science solutions can be transformed into practical applications that are accessible through modern web technologies.


Dataset Information

Dataset Name: student_performance_sample.csv

Target Variable:

  • exam_score

Input Features:

  • age
  • study_hours_per_week
  • attendance_rate
  • previous_score
  • sleep_hours
  • tutoring_sessions
  • parental_education
  • internet_access
  • extracurricular

The dataset contains student academic and behavioral information used to predict final examination performance.


Objective

The main objectives of this project are:

  • To understand and implement a complete Data Science workflow.
  • To perform data preprocessing and feature engineering.
  • To conduct Exploratory Data Analysis (EDA) for extracting insights.
  • To train and evaluate multiple machine learning models.
  • To select and save the best-performing model.
  • To deploy the trained model using FastAPI.
  • To provide real-time prediction services through API endpoints.
  • To demonstrate practical machine learning deployment in a production-like environment.

Technologies Used

Programming Language

  • Python

Libraries and Frameworks

  • Pandas
  • NumPy
  • Matplotlib
  • Scikit-learn
  • Joblib
  • FastAPI
  • Uvicorn

Project Workflow

The project follows a structured Data Science pipeline consisting of multiple stages.

1. Data Collection

A student performance dataset is used as the foundation of the project. The dataset contains information about student academic behavior and performance indicators. These attributes serve as input variables for training the machine learning model.

2. Data Cleaning

Before training the model, the dataset undergoes preprocessing and cleaning procedures, including:

  • Handling missing values
  • Removing duplicate records
  • Data type validation
  • Outlier detection and treatment
  • Data consistency checks

These steps ensure the dataset is reliable and suitable for machine learning applications.

3. Exploratory Data Analysis (EDA)

Exploratory Data Analysis is performed to understand patterns and relationships within the dataset. Various visualizations and statistical summaries are generated to identify important trends.

EDA includes:

  • Dataset overview
  • Feature distributions
  • Correlation analysis
  • Missing value analysis
  • Statistical summaries
  • Data visualization using charts and plots

Generated visualizations are stored in the outputs directory.

EDA Outputs

The following visualizations were generated during Exploratory Data Analysis:

  • exam_score_distribution.png
  • correlation_matrix.png
  • null_values.png
  • study_hours_vs_score.png
  • dataset_overview.txt

These outputs helped identify feature relationships, missing values, and performance trends within the dataset.

4. Feature Engineering and Preprocessing

Machine learning algorithms require properly formatted data. Therefore, preprocessing techniques are applied, including:

  • Numerical feature scaling using StandardScaler
  • Categorical feature encoding using One-Hot Encoding
  • Feature transformation
  • Train-test data splitting

These preprocessing steps improve model performance and ensure consistency during prediction.

5. Model Training

Multiple machine learning algorithms are trained and evaluated.

Models used:

  • Linear Regression
  • Random Forest Regressor

The models are compared using evaluation metrics such as:

  • Mean Absolute Error (MAE)
  • Root Mean Squared Error (RMSE)
  • R² Score

The best-performing model is automatically selected and saved for deployment.

6. Model Deployment

After training, the selected model is serialized and saved using Joblib. The saved model is then integrated into a FastAPI application.

The API accepts student information as input and returns predicted exam scores in JSON format.


API Endpoints

Root Endpoint

Method: GET

/

Response:

{
  "message": "Project Running Successfully"
}

This endpoint confirms that the API is running correctly.


Prediction Endpoint

Method: POST

/predict

Sample Request:

{
  "age": 18,
  "study_hours_per_week": 25,
  "attendance_rate": 90,
  "previous_score": 82,
  "sleep_hours": 7,
  "tutoring_sessions": 2,
  "parental_education": "Bachelor",
  "internet_access": "Yes",
  "extracurricular": "Yes"
}

Sample Response:

{
  "prediction": 97.37,
  "message": "Prediction generated successfully."
}

The prediction value represents the estimated final examination score based on the supplied input data.


Project Structure

Task3/
│
├── app/
│   └── main.py
│
├── data/
│
├── model/
│   └── model.joblib
│
├── outputs/
│
├── src/
│   ├── preprocessing.py
│   ├── train.py
│   └── predict.py
│
├── requirements.txt
├── README.md
└── .gitignore

How to Run the Project

Install Dependencies

pip install -r requirements.txt

Train the Model

python src/train.py

Start the FastAPI Server

uvicorn app.main:app --reload
or 
python -m uvicorn app.main:app --reload

Open Swagger Documentation

http://127.0.0.1:8000/docs

Swagger UI allows users to test API endpoints directly from the browser.


Results

The project successfully demonstrates the complete implementation of an End-to-End Data Science workflow. The trained machine learning model is capable of predicting student performance based on academic and personal factors.

Best Model

Multiple regression models were evaluated.

Models Compared:

  • Linear Regression
  • Random Forest Regressor

The best-performing model was selected automatically based on evaluation metrics and saved as:

model/model.joblib

Key achievements include:

  • Data preprocessing and cleaning
  • Exploratory Data Analysis
  • Machine learning model training
  • Model evaluation and comparison
  • Model serialization using Joblib
  • FastAPI deployment
  • Real-time prediction API
  • Interactive Swagger documentation

The API successfully generates prediction results and provides a user-friendly interface for testing through FastAPI's built-in Swagger documentation system.


Conclusion

This project successfully fulfills the requirements of an End-to-End Data Science application by integrating data preprocessing, machine learning, and API deployment into a single workflow. The implementation demonstrates how predictive models can be transformed into real-world applications using FastAPI and Python.

The project serves as a practical example of machine learning deployment and highlights the importance of combining data analysis, model development, and software engineering practices to build scalable and accessible AI-powered solutions.

Contributors

Languages