Skip to content

ThePush/ft_linear_regression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linear Regression: Predicting dependent variables from independent variables 📈

Usage:

image

1/ To generate the model, plot the results and print the statistics:

$> python3 linreg.py <file.csv> -ps

Output with training on current dataset:

image

2/ Then use the model to predict, for example, the price of a car given its mileage. The script will use the model generated by the linreg.py script and saved in the <theta.csv> file.

$> python3 prediction.py

Example of input/output:

image

Dataset generation:

The dataset used for training is in the file data.csv, you can generate another one using the generate_dataset.py script. It will generate a dataset with 2 columns. The data are based on the result of the model generated by the linreg.py script. (Not really happy with the results, I will improve it if needed.)

To use it, run:

$> python3 dataset_generator.py <filename> <number_of_rows>

About

Linear Regression from scratch, includes: MSE, Pearson correlation (r2), SEE

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages