https://github.com/jakevdp/wpca
Weighted Principal Component Analysis (PCA) in Python
https://github.com/jakevdp/wpca
Last synced: 3 months ago
JSON representation
Weighted Principal Component Analysis (PCA) in Python
- Host: GitHub
- URL: https://github.com/jakevdp/wpca
- Owner: jakevdp
- License: bsd-3-clause
- Created: 2016-01-15T15:59:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-19T00:35:48.000Z (over 7 years ago)
- Last Synced: 2025-04-24T04:16:32.251Z (3 months ago)
- Language: Jupyter Notebook
- Homepage:
- Size: 1.94 MB
- Stars: 154
- Watchers: 4
- Forks: 26
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# Weighted Principal Component Analysis in Python
*Author: Jake VanderPlas*
[](https://pypi.python.org/pypi/wpca)
[](https://pypi.python.org/pypi/wpca)
[](https://travis-ci.org/jakevdp/wpca)
[](https://github.com/jakevdp/wpca/blob/master/LICENSE)This repository contains several implementations of Weighted Principal Component
Analysis, using a very similar interface to scikit-learn's
[``sklearn.decomposition.PCA``](http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html):- ``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)](http://arxiv.org/abs/1412.4533)- ``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)](http://arxiv.org/abs/1208.4122).- ``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](WPCA-Example.ipynb).## Installation & Dependencies
This package has the following requirements:
- Python versions 2.7, or 3.4+
- [numpy](http://numpy.org/) (tested with version 1.10)
- [scipy](http://scipy.org/) (tested with version 0.16)
- [scikit-learn](http://scikit-learn.org/) (tested with version 0.17)
- [nose](http://nose.readthedocs.org/) (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
```