# Coursera ML Assignment 1 Part II

This is assignment 1 part 2 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 ex1data2.txt and ex1_multi.m.
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 for multiple input vectors along with feature normalization.
![](http://neerajkh.blob.core.windows.net/images/MLassignment_1_2_1.PNG)
The first part of the assignment is to write a normalization function, cost function and gradient descent function to find the feature weights Theta. The output of this function is the theta matrix for multiple input vectors.
![](http://neerajkh.blob.core.windows.net/images/MLassignment_1_2_2.PNG)
The last part of the assignment is to write a predict function that uses given input data, normalizes input data using mean/standard deviation and theta computed in previous step to predict the home price based on the home size and number of bedrooms.
![](http://neerajkh.blob.core.windows.net/images/MLassignment_1_2_3.PNG)
##Additional References
The part 1 of this assignment is located [here](https://gallery.azureml.net/Details/90f35b0e93c44a578c50d4d508022721)
Created by a Microsoft Employee