The previous code (in this case, using Smile) performs full PCA via full SVD or EVD. Here, full means that it computes all eigenvalues and eigenvectors, which may be computationally expensive, especially when we only need the first 7.8% of the principal components. However, we do not necessarily have to always compute the full PCA, and instead we can use truncated SVD. Truncated SVD computes only the specified number of principal components, and it is usually a lot faster than the full version.
Smile also provides an implementation of truncated SVD. But before using it, let's quickly revise SVD.
SVD of a matrix X computes the bases for the rows and the columns of X such that:
Here, the equation is explained as follows: ...