changeset 13:f07e20181cf0 default tip

Change step size in ex1_multi.m and renormalise new inputs for gradientDescentx
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Wed, 26 Oct 2011 07:57:12 -0700
parents 2af1401f7f7d
children
files ex1_multi.m
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ex1_multi.m
+++ b/ex1_multi.m
@@ -82,8 +82,8 @@
 fprintf('Running gradient descent ...\n');
 
 % Choose some alpha value
-alpha = 0.01;
-num_iters = 100;
+alpha = 0.03;
+num_iters = 1000;
 
 % Init Theta and Run Gradient Descent 
 theta = zeros(3, 1);
@@ -104,7 +104,8 @@
 % ====================== YOUR CODE HERE ======================
 % Recall that the first column of X is all-ones. Thus, it does
 % not need to be normalized.
-price = 0; % You should change this
+Price_norm = bsxfun (@rdivide, bsxfun(@minus, [1650 3], mu), sigma);
+price = [1 Price_norm]*theta; 
 
 
 % ============================================================
@@ -149,7 +150,7 @@
 
 % Estimate the price of a 1650 sq-ft, 3 br house
 % ====================== YOUR CODE HERE ======================
-price = 0; % You should change this
+price = [1 1650 3]*theta; % You should change this
 
 
 % ============================================================