mirror of
https://github.com/jlengrand/MachineLearningCoursera.git
synced 2026-03-10 08:31:20 +00:00
Finishes Week 6
This commit is contained in:
@@ -123,7 +123,7 @@ for i = 1:m
|
||||
end
|
||||
|
||||
fprintf('Program paused. Press enter to continue.\n');
|
||||
pause;
|
||||
% pause;
|
||||
|
||||
%% =========== Part 6: Feature Mapping for Polynomial Regression =============
|
||||
% One solution to this is to use polynomial regression. You should now
|
||||
@@ -153,7 +153,7 @@ fprintf('Normalized Training Example 1:\n');
|
||||
fprintf(' %f \n', X_poly(1, :));
|
||||
|
||||
fprintf('\nProgram paused. Press enter to continue.\n');
|
||||
pause;
|
||||
% pause;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,11 +15,9 @@ X_poly = zeros(numel(X), p);
|
||||
%
|
||||
%
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for i = 1:p
|
||||
X_poly(:, i) = X.^i;
|
||||
end
|
||||
|
||||
% =========================================================================
|
||||
|
||||
end
|
||||
end
|
||||
Binary file not shown.
@@ -41,10 +41,12 @@ error_val = zeros(length(lambda_vec), 1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for i = 1:length(lambda_vec)
|
||||
lambda = lambda_vec(i);
|
||||
[theta] = trainLinearReg(X, y, lambda);
|
||||
error_train(i) = linearRegCostFunction(X, y, theta, 0);
|
||||
error_val(i) = linearRegCostFunction(Xval, yval, theta, 0);
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user