Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joyhuang9473/1cbf0c9df2da3b667c8e to your computer and use it in GitHub Desktop.
Save joyhuang9473/1cbf0c9df2da3b667c8e to your computer and use it in GitHub Desktop.
Train polynomial regression and comput train error (m = 1 to 12) and cross validation error.
% Octave console output
Iteration 14 | Cost: 1.232595e-32
Iteration 25 | Cost: 4.108651e-32
Iteration 11 | Cost: 3.910038e-28
Iteration 200 | Cost: 5.989594e-08
Iteration 200 | Cost: 8.797460e-04
warning: division by zero.107198e+01
Iteration 200 | Cost: 4.639732e-02
Iteration 200 | Cost: 6.939729e-02
warning: division by zero.922449e+01
Iteration 200 | Cost: 1.814619e-01
Iteration 200 | Cost: 1.626512e-01
Iteration 200 | Cost: 1.240625e-01
Iteration 200 | Cost: 1.354165e-01
Polynomial Regression (lambda = 0.000000)
# Training Examples Train Error Cross Validation Error
1 0.000000 331.806752
2 0.000000 160.121510
3 0.000000 61.754825
4 0.000000 61.928895
5 0.000000 6.604738
6 0.000880 10.065414
7 0.046397 7.260759
8 0.069397 7.098868
9 0.181462 7.725792
10 0.162651 8.719869
11 0.124062 9.822221
12 0.135417 12.486147
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment