|
1 | 1 | \section{Description of the PLS algorithm} |
2 | 2 |
|
3 | | -\begin{frame} |
4 | | - TO DO |
5 | | -\end{frame} |
| 3 | +\begin{frame}[fragile] |
| 4 | + \frametitle{NIPALS algorithm} |
| 5 | + The most popular algorithm used in PLS to compute the model parameters is known as \textbf{non-iterative partial least squares} (\textbf{NIPALS}). There are two versions of this technique: |
| 6 | + \begin{itemize} |
| 7 | + \item \textbf{PLS1}: each of the \textit{p} predicted variables in modeled separately, resulting in one model for each class; |
| 8 | + \item \textbf{PLS2}: all predicted variables are modeled simultaneously. |
| 9 | + \end{itemize} |
| 10 | + The first algorithm is more accurate than the other, however it requires more computational time than PLS2 to find the $\alpha$ eigenvectors into which project the \textit{m} covariates. |
| 11 | +\end{frame} |
| 12 | + |
| 13 | +\begin{frame}[fragile] |
| 14 | + \frametitle{MATLAB code} |
| 15 | + The following MATLAB code implements the PLS2 algorithm: |
| 16 | + \begin{Verbatim}[tabsize=4, commandchars=\\\{\}, frame=topline] |
| 17 | +E = X; \textcolor{green}{% residual matrix for X} |
| 18 | +F = Y; \textcolor{green}{% residual matrix for Y} |
| 19 | +[~, idx] = max(sum(Y.*Y)); |
| 20 | +\textcolor{green}{% search of the j-th eigenvector} |
| 21 | +\textcolor{blue}{for} j = 1:alpha |
| 22 | + u = F(:, idx); |
| 23 | + tOld = 0; |
| 24 | + \textcolor{blue}{for} i = 1:maxIter |
| 25 | + w = (E'*u)/norm(E'*u); \textcolor{green}{% support vector} |
| 26 | + t = E*w; \textcolor{green}{% j-th column of the score matrix for X} |
| 27 | + q = (F'*t)/norm(F'*t); \textcolor{green}{% j-th column of the...} |
| 28 | + \textcolor{green}{% loading matrix for Y} |
| 29 | + u = F*q; \textcolor{green}{% j-th column of the score matrix for Y} |
| 30 | + \end{Verbatim} |
| 31 | +\end{frame} |
| 32 | + |
| 33 | +\begin{frame}[fragile] |
| 34 | + \begin{Verbatim}[tabsize=4, commandchars=\\\{\}] |
| 35 | + \textcolor{blue}{if} abs(tOld - t) < exitTol |
| 36 | + \textcolor{blue}{break}; |
| 37 | + \textcolor{blue}{else} |
| 38 | + tOld = t; |
| 39 | + \textcolor{blue}{end} |
| 40 | + \textcolor{blue}{end} |
| 41 | + p = (E'*t)/(t'*t); \textcolor{green}{% j-th column of the...} |
| 42 | + \textcolor{green}{% loading matrix of X} |
| 43 | + \textcolor{green}{% scaling} |
| 44 | + t = t*norm(p); |
| 45 | + w = w*norm(p); |
| 46 | + p = p/norm(p); |
| 47 | + \textcolor{green}{% calculation of b and the error matrices} |
| 48 | + b = (u'*t)/(t'*t); \textcolor{green}{% j-th column of the...} |
| 49 | + \textcolor{green}{% coefficient regression matrix} |
| 50 | + E = E - t*p'; |
| 51 | + F = F - b*t*q'; |
| 52 | + \end{Verbatim} |
| 53 | +\end{frame} |
| 54 | + |
| 55 | +\begin{frame}[fragile] |
| 56 | + \begin{Verbatim}[tabsize=4, commandchars=\\\{\}, frame=bottomline] |
| 57 | + \textcolor{green}{% calculation of W, P, T and B2} |
| 58 | + W(:, j) = w; |
| 59 | + P(:, j) = p; |
| 60 | + T(:, j) = t; |
| 61 | + B2 = W*(P'*W)^-1*(T'*T)^-1*T'*Y; |
| 62 | +\textcolor{blue}{end} |
| 63 | +Y_hat = X*B2; \textcolor{green}{% computation of predictions} |
| 64 | + \end{Verbatim} |
| 65 | +For each row of \verb|Y_hat| the fault class is chosen by assigning $1$ to the column whose value si greater than that of the others, $0$ otherwise. Moreover, to increase the performances of PLS it is necessary \textbf{normalize} both $X$ and $Y$ before running the algorithm. |
| 66 | + |
| 67 | +\end{frame} |
0 commit comments