From fd5fe70ce5271f09303b51dae34b42acc47f5730 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Mon, 23 Mar 2026 21:17:11 +0100 Subject: Initial commit: linear regression for car price prediction Training, prediction, and visualization programs using gradient descent with min-max normalization. --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d6833d --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# ft_linear_regression + +A simple linear regression implementation using gradient descent to predict car prices based on mileage. + +## Requirements + +- Python 3 +- matplotlib (for visualization only) + +``` +pip install matplotlib +``` + +## Usage + +### Train the model + +``` +python3 train.py +``` + +Example: +``` +python3 train.py 1.0 1000 +``` + +This trains the model on `data.csv` and saves the resulting parameters (θ0, θ1) to `thetas.csv`. + +### Predict a price + +``` +python3 predict.py +``` + +Prompts for a mileage value and outputs the estimated price. Loops until Ctrl+C. +If no trained model is found, θ0 and θ1 default to 0. + +### Visualize + +``` +python3 visualize.py +``` + +Displays a scatter plot of the dataset. If a trained model exists, the regression line is drawn on top. + +## How it works + +The model fits a linear function: + +``` +estimatePrice(mileage) = θ0 + θ1 * mileage +``` + +Parameters are found via gradient descent with min-max normalization on the input data. After training, thetas are denormalized so they work directly on raw mileage values. -- cgit v1.2.3