Simple Linear Regression algorithm created in python from scratch (no Machine Learning Libraries used).
Just download the script from git.
Then install the additional libraries:
(sudo) pip install matplotlib
(sudo) pip install numpy
(sudo) pip install drawnow
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
For more information on the topic check out Andrew Ng's Machine Learning Course.