Skip to content

jakevdp/wpca

Weighted Principal Component Analysis in Python

Author: Jake VanderPlas

version status downloads build status license

This repository contains several implementations of Weighted Principal Component Analysis, using a very similar interface to scikit-learn's sklearn.decomposition.PCA:

  • wpca.WPCA uses a direct decomposition of a weighted covariance matrix to compute principal vectors, and then a weighted least squares optimization to compute principal components. It is based on the algorithm presented in Delchambre (2014)

  • wpca.EMPCA uses an iterative expectation-maximization approach to solve simultaneously for the principal vectors and principal components of weighted data. It is based on the algorithm presented in Bailey (2012).

  • wpca.PCA is a standard non-weighted PCA implemented using the singular value decomposition. It is mainly included for the sake of testing.

Examples and Documentation

For an example application of a weighted PCA approach, See WPCA-Example.ipynb.

Installation & Dependencies

This package has the following requirements:

  • Python versions 2.7, or 3.4+
  • numpy (tested with version 1.10)
  • scipy (tested with version 0.16)
  • scikit-learn (tested with version 0.17)
  • nose (optional) to run unit tests.

With these requirements satisfied, you can install this package by running

$ pip install wpca

or to install from the source tree, run

$ python setup.py install

To run the suite of unit tests, make sure nose is installed and run

$ nosetests wpca

About

Weighted Principal Component Analysis (PCA) in Python

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published