/wlra

Weighted low rank approximation

Primary LanguagePythonMIT LicenseMIT

Weighted low rank approximation

Introduction

We are interested in solving the weighted low-rank approximation problem:

\[ min\mathbf{Z} ∑i,j wij \left(xij - zij \right)^2 \]

where \(n × p\) target matrix \(\mathbf{X}\) and \(n × p\) weight matrix \(\mathbf{W}\) are given, and \(\mathbf{Z}\) is constrained to some rank.

Solving WLRA allows us to solve two main problems:

  1. Learn low rank structure in non-Gaussian data. Using Taylor expansion of non-Gaussian likelihoods, we can rewrite the MLE of factor models as the solution to WLRA. The key idea is that the Taylor expansion is performed around a different value for each observation, naturally leading to an iterative approach.
  2. Handle truly missing data. By setting weights to zero, we can code missing data. This approach works even in settings where observations can also take the value zero, such as single cell RNA sequencing data.

Installation

pip install git+https://www.github.com/aksarkar/wlra.git#egg=wlra

Example

np.random.seed(0)
l = np.random.normal(size=(n, 3))
f = np.random.normal(size=(3, p))
eta = l.dot(f)
x = np.random.poisson(lam=np.exp(eta))
res = pois_lra(x, rank=3)