Skip to content

grtlr/uapca

Repository files navigation

Uncertainty-aware principal component analysis

Build Status npm GitHub

This is an implementation of uncertainty-aware principal component analysis, which generalizes PCA to work on probability distributions. You can find a live Observable notebook demonstrating our method here.

Teaser

You can find a preprint of our paper at arXiv:1905.01127 or on my personal website. We also extracted means and covariances from the student grades dataset.

Example

// Loading the library
import * as uapca from 'uapca';

// Loading and converting the dataset
const student_grades = (await fetch('https://raw.githubusercontent.com/grtlr/uapca/master/data/student_grades.json')).json();
const distributions = student_grades.distributions.map(d => new uapca.MultivariateNormal(d.mean, d.cov));

// Perform uncertainty-aware PCA with scaling factor k = 0.5
const pca = uapca.UaPCA.fit(distributions, 0.5).aligned();

// Project the data onto 2D
const projected_distributions = pca.transform(distributions, 2);

Development

The dependencies can be install using yarn:

yarn install

Builds can be prepared using:

yarn run build
yarn run dev # watches for changes

Run tests:

yarn run test

To perform linter checks you there is:

yarn run lint
yarn run lint-fix # tries to fix some of the warnings

Citation

To cite this work, you can use the BibTex entry in CITATION.cff.