Skip to content

Instantly share code, notes, and snippets.

Train linear regression and comput train error (m = 1 to 12) and cross validation error.
% Octave console output
Iteration 3 | Cost: 9.860761e-32
Iteration 2 | Cost: 3.286595e+00
Iteration 28 | Cost: 2.842678e+00
Iteration 24 | Cost: 1.315405e+01
Iteration 27 | Cost: 1.944396e+01
Iteration 13 | Cost: 2.009852e+01
Iteration 30 | Cost: 1.817286e+01
Iteration 11 | Cost: 2.260941e+01
Iteration 33 | Cost: 2.326146e+01
Iteration 10 | Cost: 2.431725e+01
Iteration 2 | Cost: 2.237391e+01
# Training Examples Train Error Cross Validation Error
1 0.000000 210.522449
2 0.000000 110.300366
3 3.286595 45.010231
4 2.842678 48.368911
5 13.154049 35.865165
6 19.443963 33.829962
7 20.098522 31.970986
8 18.172859 30.862446
9 22.609405 31.135998
10 23.261462 28.936207
11 24.317250 29.551432
12 22.373906 29.433818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment