% =========== Part 2: Regularized Linear Regression Cost ============= % You should now implement the cost function for regularized linear % regression. % theta = [1 ; 1]; J = linearRegCostFunction([ones(m, 1) X], y, theta, 1); fprintf(['Cost at theta = [1 ; 1]: %f '... '\n(this value should be about 303.993192)\n'], J); fprintf('Program paused. Press enter to continue.\n'); theta = [1 ; 1]; [J, grad] = linearRegCostFunction([ones(m, 1) X], y, theta, 1); fprintf(['Gradient at theta = [1 ; 1]: [%f; %f] '... '\n(this value should be about [-15.303016; 598.250744])\n'], ... grad(1), grad(2)); fprintf('Program paused. Press enter to continue.\n');