<commit_before># Weighted Principal Component Analysis in Python

In this repository I am exploring various approaches to weighted principal
component analysis. This is very much a work in progress, though I'm trying
to document the code enough to make it useful!<commit_msg>DOC: update README<commit_after># Weighted Principal Component Analysis in Python

This repository contains several implementations of Weighted Principal Component
Analysis, using the same interface as scikit-learn's
[``sklearn.decomposition.PCA``](http://scikit-learn.org/):

- ``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 (2104)](http://arxiv.org/abs/1412.4533)

- ``wpca.EMPCA`` uses an iterative expectation-maximization approach to solve
  simultaneously for the principal vectors and principal components. 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.6-2.7, or 3.3-3.5
- [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://nosetests.readthedocs.org) (optional) to run unit tests.

With these requirements satisfied, you can install this package by running
```
$ python setup.py install
```
To run the unit tests, make sure ``nose`` is installed and run
```
$ nosetests wpca
```
{'fraction_non_alphanumeric': 0.09387966804979253, 'fraction_numerical': 0.021265560165975105, 'mean_word_length': 4.75820895522388, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '277632', 'n_tokens_mistral': 589, 'n_tokens_neox': 534, 'n_words': 223}