This repository contains a simple Python implementation of a linear regression model that predicts exam scores based on study hours. The project is part of the University of Luxembourg Workshop (October 12th, 2024) and is published here for anyone interested in revisiting the material discussed during the workshop.
This project demonstrates how to use a basic linear regression model to predict exam scores from the number of hours studied. The training data consists of three student records, with each entry representing the hours studied and the corresponding exam score.
This example was covered in the University of Luxembourg Workshop, and this repository provides an opportunity to revisit and understand the concepts of machine learning, specifically linear regression.
The model aims to learn a relationship between the number of hours studied (input) and the exam score (output). It adjusts its parameter ( w ) to minimize the error between predicted and actual scores using a simple gradient descent algorithm.
- Student A: Studied 1 hour, scored 50 points.
- Student B: Studied 3 hours, scored 65 points.
- Student C: Studied 5 hours, scored 80 points.
The model finds the best parameter ( w ) to make accurate predictions based on this data.
- Initial guess for ( w ): Starts at 10.0.
- Learning rate: 0.01
- Stopping criterion: Converges when the change in ( w ) is smaller than the tolerance of 1e-6.
The model iterates over the data, adjusts ( w ) to minimize the prediction error, and stops when convergence is reached.
Here’s a simplified explanation of the code:
- Initialize Parameters: Set an initial guess for ( w ) and define the learning rate, number of epochs, and tolerance for convergence.
- Training Loop: For each epoch, the model:
- Predicts exam scores.
- Computes errors based on actual scores.
- Updates ( w ) using gradient descent.
- Checks for convergence.
- Final Output: Prints the learned value of ( w ) and the final predictions.
To run this project, clone the repository and execute the Python script.
git clone https://github.com/SteveProkovas/University-of-Luxembourg-Workshop.git
cd University-of-Luxembourg-Workshop
python Example.py
- Python 3.x
- No external libraries are required for this implementation.
You can view the slides from the University of Luxembourg Workshop here.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.