This routine is implemented in Matlab
Matlab2012b and its latest version
This routine using GradientDescent to do the Linear Regression and Classification. I set two questions as an example:
-
We think the height of human has a close relationship with the weight of human, Now we get 15 american women's (Age:30-39)heights and weights, We assume the predict function is y=b1+a1x+a2x^2 (x is height and y is weight). So we can get the optimum predict function between than.
-
Based on the length & width of the sepal and length and width of the petal, predict what kind of Iris it is (Two kinds:
setosa
&versicolor
), the dataset is come fromUCI Machine Learning Repository
URL:http://archive.ics.uci.edu/ml/datasets/Iris -
The Screenshot of the result:
- Download the whole runtine.
- Run :
Master.m
make sure all m-files are in the same folder.
- This runtine is based on the Course of Machine Learning (Andrew Ng)in Coursera.
- I have splited each important step of the Algorithm of GD (GradientDescent)into different script files. So it is no difficult to understand. If you have any problem of the algorithm of GD. You can have a look at this article: https://www.kdnuggets.com/2017/04/simple-understand-gradient-descent-algorithm.html