NOTES:
- The script for running the code as done by me in preparing this assignment, is written to be used in IPython 1. A detailed session (with outputs as well, is given in session.ipy)
- This document has some equations that require javascript to run, and an internet connection (to http://orgmode.org/ for the functions).
I used this code: #+INCLUDE “code/hw2.py” src python :lines “1-17”
#+INCLUDE “code/session.ipy” src python :lines “5-14”
And got this scatter plot (Figure 1):
I used #+INCLUDE “code/hw2.py” src python :lines “19-30”
and ran #+INCLUDE “code/session.ipy” src python :lines “16-38”
to get Figure 2
but this seemed a bit to small of an error, so I also ran: #+INCLUDE “code/session.ipy” src python :lines “39-56”
to get Figure 3:
Which I feel makes the point of over-fitting more obvious.
Using the standard penalty function:
\begin{equation} EW(w) = \frac{1}{2} WT⋅ W = \frac{1}{2} ∑m=1MWm2 \end{equation}
and the given solution to the penalized least-squares problem: \begin{equation} WPLS = (ΦTΦ + λ \mathrm{I})-1ΦTt \end{equation}
I wrote: #+INCLUDE “code/hw2.py” src python :lines “31-46”
To generate the 3 slices of the data set: #+INCLUDE “code/hw2.py” src python :lines “47-59”
To get the error term for given $xi$, $ti$
#+INCLUDE “code/session.ipy” src python :lines “57-82” Producing:
#+INCLUDE “code/session.ipy” src python :lines “84-116”
My conclusion is that (as pointed out in class) choosing the LoptimizePLS(xt, tt, xv, tv, M)
such that it will choose the
#+INCLUDE “code/hw2.py” src python :lines “87-104”
To return the following equations:
\begin{equation} m(x) = \frac{1}{σ2} Φ(x)T S ∑n=1NΦ(xn) tn \end{equation}
\begin{equation} var(x) = S2(x) = σ2 + Φ(x)T S Φ(x) \end{equation}
\begin{equation} S-1 = α I + \frac{1}{σ2} ∑n=1NΦ(xn)Φ(xn)T \end{equation}
The implementation is: #+INCLUDE “code/hw2.py” src python :lines “106-128”
running: #+INCLUDE “code/session.ipy” src python :lines “112-127” resulted in Figure 4:
and for
BUT Bishop used
We should notice that in contrast to bishop (see below), in our graph, the $σ2$ values visibly decrease on ‘linear’ parts of the sinusoidal, and increase on ‘curved’ ones.
1 Fernando Pérez, Brian E. Granger, IPython: A System for Interactive Scientific Computing, Computing in Science and Engineering, vol. 9, no. 3, pp. 21-29, May/June 2007, doi:10.1109/MCSE.2007.53. URL: http://ipython.org