pytorch-pca icon indicating copy to clipboard operation
pytorch-pca copied to clipboard

Minimal implementation of PCA in PyTorch, tested against scikit-learn's implementation

If I try and write PCA from memory in PyTorch I always make a mistake so it doesn't do exactly the same thing as scikit-learn's PCA with the same settings. This is a minimal implementation of PCA that matches scikit-learn's with default settings (run pca.py to test this).

Install

Open pca.py, copy the code you'd like to use and then paste it where you'd like to use it.