empca

Principal Component Analysis (PCA) for Missing and/or Noisy Data

https://github.com/sbailey/empca

Science Score: 38.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.1%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Principal Component Analysis (PCA) for Missing and/or Noisy Data

Basic Info
  • Host: GitHub
  • Owner: sbailey
  • License: other
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 16.6 KB
Statistics
  • Stars: 72
  • Watchers: 8
  • Forks: 24
  • Open Issues: 5
  • Releases: 0
Created over 14 years ago · Last pushed over 9 years ago
Metadata Files
Readme License Citation

README.md

empca: Weighted Expectation Maximization Principal Component Analysis

Classic PCA is great but it doesn't know how to handle noisy or missing data properly. This module provides Weighted Expectation Maximization PCA, an iterative method for solving PCA while properly weighting data. Missing data is simply the limit of weight=0.

Given data[nobs, nvar] and weights[nobs, nvar],

m = empca(data, weights, options...)

That returns a Model object m, from which you can inspect the eigenvectors, coefficients, and reconstructed model, e.g.

pylab.plot( m.eigvec[0] )
pylab.plot( m.data[0] )
pylab.plot( m.model[0] )

If you want to apply the model to new data:

m.set_data(new_data, new_weights)

and then it will recalculate m.coeff, m.model, m.rchi2, etc. for the new data.

m.R2() is the fraction of data variance explained by the model, while m.R2vec(i) is the amount of variance explained by eigenvector i.

This implementation of EMPCA does not subtract the mean from the data. If you don't subtract the mean yourself, it will still work, with the first eigenvector likely being something similar to the mean.

For comparison, two alternate methods are also implemented which also return a Model object:

m = lower_rank(data, weights, options...)
m = classic_pca(data)  #- but no weights or even options...

Everything is self contained in empca.py . Just put that into your PYTHONPATH and "pydoc empca" for more details. For a quick test on toy example data, run

python empca.py

This requires numpy and scipy; it will make plots if you have pylab installed.

The paper S. Bailey 2012, PASP, 124, 1015 describes the underlying math and is available as a pre-print at:

http://arxiv.org/abs/1208.4122

If you use this code in an academic paper, please include a citation as described in CITATION.txt, and optionally an acknowledgement such as:

This work uses the Weighted EMPCA code by Stephen Bailey, available at https://github.com/sbailey/empca/

The examples in the paper were prepared with version v0.2 of the code.

Stephen Bailey, Summer 2012

Owner

  • Name: Stephen Bailey
  • Login: sbailey
  • Kind: user

Physicist software developer at Lawrence Berkeley National Laboratory, leading software development for the world's largest 3D map of the universe.

Citation (CITATION.txt)

If you use this code in an academic paper, please include a citation to
S. Bailey 2012, PASP, 124, 1015 and optionally an acknowledgement such as:

> This work uses the Weighted EMPCA code by Stephen Bailey,
> available at https://github.com/sbailey/empca/

BibTeX entry:

@ARTICLE{2012PASP..124.1015B,
   author = {{Bailey}, S.},
    title = "{Principal Component Analysis with Noisy and/or Missing Data}",
  journal = {\pasp},
archivePrefix = "arXiv",
   eprint = {1208.4122},
 primaryClass = "astro-ph.IM",
 keywords = {Data Analysis and Techniques},
     year = 2012,
    month = sep,
   volume = 124,
    pages = {1015-1023},
      doi = {10.1086/668105},
   adsurl = {http://adsabs.harvard.edu/abs/2012PASP..124.1015B},
  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

GitHub Events

Total
  • Watch event: 5
Last Year
  • Watch event: 5

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 23
  • Total Committers: 2
  • Avg Commits per committer: 11.5
  • Development Distribution Score (DDS): 0.478
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Stephen Bailey S****y@l****v 12
Stephen Bailey s****e@g****m 11
Committer Domains (Top 20 + Academic)
lbl.gov: 1