Princiapal Component Analysis (PCA) clearly explained and implemented from scratch in Python:
First Import numpy and define a class named "PCA" to encapsulate the operations.
In the __init__ constructor let's initialize the number of components to reduce to, which is n_components, and similarly create placeholders for mean and eigenvectors.
Now define the "fit" method that takes in that data and calculates the mean, normalizes the data, computes the covariance matrix, eigenvalues, and eigenvectors.
Then the Eigenvectors are sorted based on eigenvalues.
You may ask how, eigen vectors does dimensionality reduction?