Skip to content

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

License

Notifications You must be signed in to change notification settings

gngdb/pytorch-pca

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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).

Now includes:

  • pca.py: matches sklearn's PCA
  • incremental_pca.py: matches sklearn's IncrementalPCA, contributed by: yry

Install

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

Related Work

  • valentingol's torch_pca appears to be a more full featured and faster (it chooses an appropriate PCA algorithm depending on input dimensions) alternative PCA implementation also matching scikit-learn.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages