This project implements a simple linear regression model from scratch using Python. The model is trained using gradient descent to predict student scores based on the number of hours they studied.
The script LinearRegression.py performs the following steps:
- Loads the student scores data from
score_updated.csv. - Initializes the model parameters (slope
mand y-interceptb). - Implements a loss function (Mean Squared Error).
- Uses gradient descent to minimize the loss and find the best values for
mandb. - Visualizes the original data points and the final regression line using
matplotlib.
The dataset used is score_updated.csv, which contains two columns:
Hours: The number of hours a student studied.Scores: The score obtained by the student.
The project requires the following Python libraries:
- pandas
- matplotlib
Make sure you have Python installed on your system.
- Clone the repository or download the source code.
- Install the required packages using pip:
pip install -r requirements.txt
To run the linear regression model, execute the following command in your terminal:
python LinearRegression.pyThe script will print the final values for the slope (m) and y-intercept (b) and then display a plot showing the data points and the fitted regression line.