|
|
|
@ -39,14 +39,14 @@ error_val = zeros(length(lambda_vec), 1);
|
|
|
|
|
%
|
|
|
|
|
%
|
|
|
|
|
|
|
|
|
|
for i = 1:length(lambda_vec)
|
|
|
|
|
lambda = lambda_vec(i);
|
|
|
|
|
theta = trainLinearReg(X, y, lambda);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lambda = 0;
|
|
|
|
|
error_train(i) = linearRegCostFunction(X, y, theta, lambda);
|
|
|
|
|
error_val(i) = linearRegCostFunction(Xval, yval, theta, lambda);
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
% =========================================================================
|
|
|
|
|
|
|
|
|
|