Skip to content

Simple Linear Regression algorithm created in python from scratch (no Machine Learning Libraries)

Notifications You must be signed in to change notification settings

catalinlup/LinearRegression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

LinearRegression

Simple Linear Regression algorithm created in python from scratch (no Machine Learning Libraries used).

Installation

Just download the script from git.
Then install the additional libraries:
(sudo) pip install matplotlib
(sudo) pip install numpy
(sudo) pip install drawnow

How to use it?

Run the script from console:
python LinearRegression.py argv1 argv2 argv3 argv4
argv1 - is the training data. It should be formated like train.csv. The first column represents the x value, the second represents the y value
argv2 - is the output file. The script will output 2 values(t0 and t1) representing the coefficients of the hypothesis:
h(x)=t0+x*t1
argv3 - is the learning rate alfa
argv4 - is a threshold value.
Gradient Descent stops when abs(oldCostFunctionValue-CostFunctionValue)'<'threshold. For better accuracy use a lower threshold value (ex:0.01)
Command example:
python LinearRegression.py train.csv model.txt 0.0001 1

Details

For more information on the topic check out Andrew Ng's Machine Learning Course.

Hope you enjoy it!

About

Simple Linear Regression algorithm created in python from scratch (no Machine Learning Libraries)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages