Student Score Prediction Using Machine Learning

1. Introduction

Student Score Prediction is a beginner-friendly Machine Learning project that focuses on predicting a student's exam score based on the number of hours they study. Students spend different amounts of time preparing for examinations, and their study time can have a relationship with their academic performance. Machine Learning can be used to analyze this relationship and make predictions for new students.

In this project, historical student data is used to train a Machine Learning model. The dataset contains the number of hours each student studied and the corresponding exam score they achieved. The model learns the relationship between these two variables and uses the learned pattern to predict the expected score of a new student.

This is a Supervised Machine Learning problem because the training dataset contains both the input value and the expected output value. The number of hours studied is the input feature, while the exam score is the target value.

Since the exam score is a continuous numerical value, this problem is considered a Regression problem. For this project, Linear Regression is used because it is one of the simplest and most commonly used regression algorithms.

The model attempts to find a linear relationship between study hours and exam scores. Once the relationship is learned, the model can estimate the score for a student who provides a new number of study hours.

2. Objective

The main objective of this project is to build a Machine Learning model that learns the relationship between study hours and exam scores and then predicts the expected score for a new student.

The project also demonstrates important Machine Learning concepts such as:

  • Dataset creation

  • Feature selection

  • Target variable selection

  • Model training

  • Linear Regression

  • Prediction

  • Result interpretation

3. Technologies Used

The following technologies are used in this project:

  • Python – Programming language used to implement the model.

  • Pandas – Used to create and manage the student dataset.

  • Scikit-learn – Used to implement the Linear Regression algorithm.

  • Linear Regression – Used to predict the student's continuous exam score.

4. Dataset

The dataset contains sample student records. Each record contains two values:

  • Hours_Studied – Number of hours the student studied.

  • Score – Exam score achieved by the student.

The sample dataset contains eight student records.

Dataset

   Hours_Studied  Score
0              1     35
1              2     40
2              3     50
3              4     55
4              5     65
5              6     70
6              7     80
7              8     90

From the dataset, we can observe that students who studied more hours generally achieved higher scores. The Machine Learning model uses this pattern to learn the relationship between the two variables.

5. Working Principle

The system follows a simple Machine Learning workflow.

First, the student dataset is created using Pandas. The dataset contains the study hours and corresponding exam scores.

Next, the Hours_Studied column is selected as the input feature, represented by X. The Score column is selected as the target variable, represented by y.

A Linear Regression model is then created using Scikit-learn. The model is trained using the fit() function. During training, the algorithm analyzes the relationship between the number of hours studied and the exam scores.

After training, a new student's study time is provided to the model. In this example, the student studies for 6.5 hours.

The trained model uses the relationship it learned from the historical data to calculate the predicted exam score.

6. Python Implementation

The following Python program implements the Student Score Prediction system.

# Import required libraries

import pandas as pd
from sklearn.linear_model import LinearRegression

# --------------------------------------------
# Step 1: Create the dataset
# --------------------------------------------

# Sample student data

data = {
    "Hours_Studied": [1, 2, 3, 4, 5, 6, 7, 8],
    "Score": [35, 40, 50, 55, 65, 70, 80, 90]
}

# Convert dictionary into a DataFrame

df = pd.DataFrame(data)

# Display dataset

print("Dataset:")
print(df)

# --------------------------------------------
# Step 2: Select input feature (X)
# --------------------------------------------

# Independent variable

X = df[["Hours_Studied"]]

# --------------------------------------------
# Step 3: Select output variable (y)
# --------------------------------------------

# Dependent variable

y = df["Score"]

# --------------------------------------------
# Step 4: Create the Linear Regression model
# --------------------------------------------

model = LinearRegression()

# --------------------------------------------
# Step 5: Train the model
# --------------------------------------------

model.fit(X, y)

# --------------------------------------------
# Step 6: Predict a student's score
# --------------------------------------------

# Student studies for 6.5 hours

new_student = [[6.5]]

predicted_score = model.predict(new_student)

# --------------------------------------------
# Step 7: Display prediction
# --------------------------------------------

print("\nPredicted Student Score:")
print(f"{predicted_score[0]:.2f}")

7. Explanation of the Python Program

The program starts by importing the required libraries. Pandas is used to create the dataset and manage the student data, while LinearRegression from Scikit-learn is used to create the Machine Learning model.

In Step 1, a Python dictionary is created containing the number of hours studied and the corresponding exam scores. This dictionary is converted into a Pandas DataFrame.

In Step 2, the Hours_Studied column is selected as the input feature. It is stored in the variable X. This represents the independent variable because the model uses study hours to make the prediction.

In Step 3, the Score column is selected as the target variable and stored in y. This is the value that the Machine Learning model needs to predict.

In Step 4, a Linear Regression model is created using:

model = LinearRegression()

In Step 5, the model is trained using:

model.fit(X, y)

During training, the model learns the mathematical relationship between study hours and exam scores.

In Step 6, a new student is introduced. This student studies for 6.5 hours. The value is provided to the trained model using the predict() function.

Finally, the predicted score is displayed using two decimal places.

8. Prediction

Input

Student studies for 6.5 hours

Output

Predicted Student Score:
75.00

The model predicts that a student who studies for 6.5 hours is expected to achieve a score of approximately 75.00.

This prediction is based on the relationship learned from the sample historical data.

9. How Linear Regression Works

Linear Regression attempts to find the best-fitting straight line through the available data points. The basic equation can be represented as:

y = mx + b

Where:

  • y = Predicted score

  • x = Hours studied

  • m = Slope of the line

  • b = Intercept

The model calculates suitable values for the slope and intercept based on the training data. When a new study-hour value is provided, the equation is used to estimate the corresponding exam score.

In this example, the data generally shows a positive relationship between study time and exam performance. Therefore, as the number of study hours increases, the predicted score also tends to increase.

10. Advantages

This Student Score Prediction system has several advantages:

  • Simple and easy to understand.

  • Uses a basic Machine Learning algorithm.

  • Easy to implement using Python.

  • Demonstrates supervised learning.

  • Can predict continuous numerical values.

  • Helps beginners understand regression problems.

  • Can be extended with additional student-related features.

11. Limitations

The main limitation of this project is that it uses a very small sample dataset. Real student performance depends on many factors besides study hours.

For example, exam performance may also be influenced by:

  • Previous academic performance

  • Attendance

  • Learning ability

  • Study environment

  • Sleep and rest

  • Difficulty of the examination

  • Teaching quality

  • Subject knowledge

  • Study methods

Therefore, study hours alone cannot accurately determine a student's actual performance in every situation.

The model also assumes a relatively simple relationship between study hours and exam scores. Real-world educational data may contain more complex relationships that require more advanced Machine Learning algorithms.

12. Future Improvements

The project can be improved by using a larger dataset containing information about many students. Additional features such as attendance percentage, previous exam scores, assignment marks, practice test scores, and study methods can be included.

Different Machine Learning algorithms can also be tested and compared. For example, Decision Trees, Random Forest, Support Vector Regression, and Neural Networks could be used to determine whether they provide better predictions.

A train-test split can also be introduced to evaluate how well the model performs on unseen student data. Metrics such as Mean Absolute Error (MAE), Mean Squared Error (MSE), and R² Score can be used to measure model performance.

13. Conclusion

The Student Score Prediction Using Machine Learning project demonstrates how a simple regression algorithm can be used to predict a student's exam score based on study hours.

The project uses Linear Regression to learn the relationship between the number of hours studied and the corresponding exam scores in the training dataset. After training, the model predicts a score of 75.00 for a student who studies for 6.5 hours.

Although the project uses a small and simple dataset, it provides a clear introduction to supervised learning, regression, feature selection, model training, and prediction. With a larger dataset and additional student-related features, the system could be developed into a more comprehensive academic performance prediction system.