ageron / handson-ml2

A series of Jupyter notebooks that walk you through the fundamentals of Machine Learning and Deep Learning in Python using Scikit-Learn, Keras and TensorFlow 2.
Apache License 2.0
27.76k stars 12.73k forks source link

CHAPTER 08-PCA FROM SCRATCH #243

Open jinzus opened 4 years ago

jinzus commented 4 years ago

I have a question, why are you applying a SVD on a zero-mean (along the first axis) matrix? I'm not sure that's correct, I think you need to apply the SVD to the covariance matrix. In fact, when checking the pca.explained_varianceratio, that corresponds only to component of the vector S returned by the SVD (normalized to the sum of elements in the vector) applied on a covariance matrix.

TobiLang commented 4 years ago

PCA preparation consists of two steps:

In PCA, the principal components are the n-Eigenvectors with the largest Eigenvalues. This can be done either by: