Compute the test set error
This commit is contained in:
parent
78830aaea7
commit
2ab445f9a8
1 changed files with 21 additions and 13 deletions
|
@ -218,3 +218,11 @@ end
|
||||||
|
|
||||||
fprintf('Program paused. Press enter to continue.\n');
|
fprintf('Program paused. Press enter to continue.\n');
|
||||||
pause;
|
pause;
|
||||||
|
|
||||||
|
% Computing test set error
|
||||||
|
[~, best_i] = min(error_val, [], 1);
|
||||||
|
lambda_best = lambda_vec(best_i);
|
||||||
|
theta_best = trainLinearReg(X_poly, y, lambda_best);
|
||||||
|
error_test = linearRegCostFunction(X_poly_test, ytest, theta_best, 0);
|
||||||
|
fprintf('Test set error for best lambda = %f: %f\n', ...
|
||||||
|
lambda_best, error_test);
|
||||||
|
|
Reference in a new issue