Coursera ML Assignment 1 Part 1

April 20, 2015
This is assignment 1 part 1 for ML course by Andrew Ng.
This is part of [Introduction to ML](https://class.coursera.org/ml-003/assignment) course by Andrew Ng on coursera using ex1data1.txt. This assignment is done in R using the formulas suggested as part of the assignment. This assignment also tries to predict using linear regression algorithm built in Azure ML. Since algorithms in R are using the exact same approach as highlighted in the course, answers match with the results shown in the course. While the built-in algorithms are more optimized for practical applications, answers don't match exactly with the results shown in the course. The overall experiment is shown below. In the experiment, left-hand side is using the built-in Azure algorithms while right-hand side of the graph is using R-scripts to create gradient descent based linear regression algorithm. ![](http://neerajkh.blob.core.windows.net/images/ML_assignment1_1_1.PNG) The first part of the assignment requires a plot of the input data to observe any correlation that may be easy to discern. ![](http://neerajkh.blob.core.windows.net/images/ML_assignment1_1_2.PNG) The second part of the assignment is to write a cost function and gradient descent function using cost function to find the feature weights Theta. The output of this function is the theta matrix. ![](http://neerajkh.blob.core.windows.net/images/ML_assignment1_1_3.PNG) The last part of the assignment is to write a predict function that uses given input data and theta computed in the previous step to predict the profit based on the population. ![](http://neerajkh.blob.core.windows.net/images/ML_assignment1_1_4.PNG) ## Additional References Part II of this assignment is located [here](https://gallery.azureml.net/Details/72e5f1c8291e40aab12128dcb1f65ed4) Created by a Microsoft Employee