Motivation

Since many machine learning algorithms rely on matrices it is important to master matrix manipulation. Therefore, the following assignment is proposed.

Assignment

The successful student should demonstrate a clean implementation of the NIPALS algorithm. In statistics, non-linear iterative partial least squares (NIPALS) is an algorithm for computing the first few components in a principal component or partial least squares analysis. For very-high-dimensional datasets it is usually only necessary to compute the first few principal components.

Here is the description of the algorithm: pca_nipals.

$$\begin{pmatrix}0.5376671395461 & -1.34988694015652 & 0.671497133608081 & 0.888395631757642 & -0.102242446085491\cr 1.83388501459509 & 3.03492346633185 & -1.20748692268504 & -1.14707010696915 & -0.241447041607358\cr -2.25884686100365 & 0.725404224946106 & 0.717238651328839 & -1.06887045816803 & 0.319206739165502\cr 0.862173320368121 & -0.0630548731896562 & 1.63023528916473 & -0.809498694424876 & 0.312858596637428\cr 0.318765239858981 & 0.714742903826096 & 0.488893770311789 & -2.9442841619949 & -0.864879917324457\cr -1.30768829630527 & -0.204966058299775 & 1.03469300991786 & 1.4383802928151 & -0.0300512961962686\cr -0.433592022305684 & -0.124144348216312 & 0.726885133383238 & 0.325190539456198 & -0.164879019209038\cr 0.34262446653865 & 1.48969760778547 & -0.303440924786016 & -0.754928319169703 & 0.627707287528727\cr 3.57839693972576 & 1.40903448980048 & 0.293871467096658 & 1.37029854009523 & 1.09326566903948\cr 2.76943702988488 & 1.41719241342961 & -0.787282803758638 & -1.7115164188537 & 1.1092732976144\end{pmatrix}$$

Hint: The second T component is

$$\begin{pmatrix}1.660216125606425\cr -1.051259702224144\cr -1.669934902174654\cr 0.2265172335344322\cr -2.365906683261095\cr 1.06347394301301\cr 0.4215061657724768\cr -0.6249919834179163\cr 2.693294214551594\cr -0.3529144114001289\end{pmatrix}$$

and P  is

$$\begin{pmatrix}0.4233935251355345\cr -0.2926014769271022\cr 0.1433716236799124\cr 0.8271416668709591\cr 0.1743661062899016\end{pmatrix}$$