Skip to main content

Python code for a few approaches at matrix completion.

Project description

Matrix completion in Python

Last update: February 2019.


Python code for a few approaches at low-dimensional matrix completion.

These methods operate in-memory and do not scale beyond size 1000 x 1000 or so.

Methods

  1. Nuclear norm minimization (very slow) [1]
  2. Singular value thresholding [2]
  3. Alternating least squares [3,4]
  4. Biased alternating least squares [5]

Usage

import numpy as np
from matrix_completion import svt_solve, calc_unobserved_rmse

U = np.random.randn(20, 5)
V = np.random.randn(15, 5)
R = np.random.randn(20, 15) + np.dot(U, V.T)

mask = np.round(np.random.rand(20, 15))
R_hat = svt_solve(R, mask)

print("RMSE:", calc_unobserved_rmse(U, V, R_hat, mask))

Note that here, the mask is a matrix with entries either 1 (indicating observed) or 0 (indicating missing).

See the examples/ directory for more details.

References

[1] Emmanuel Candès and Benjamin Recht. 2012. Exact matrix completion via convex optimization. Commun. ACM 55, 6 (June 2012), 111-119. DOI: https://doi.org/10.1145/2184319.2184343

[2] Jian-Feng Cai, Emmanuel J. Candès, and Zuowei Shen. 2010. A Singular Value Thresholding Algorithm for Matrix Completion. SIAM J. on Optimization 20, 4 (March 2010), 1956-1982. DOI=http://dx.doi.org/10.1137/080738970

[3] Yifan Hu, Yehuda Koren, and Chris Volinsky. 2008. Collaborative Filtering for Implicit Feedback Datasets. In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (ICDM '08). IEEE Computer Society, Washington, DC, USA, 263-272. DOI=http://dx.doi.org/10.1109/ICDM.2008.22

[4] Ruslan Salakhutdinov and Andriy Mnih. 2007. Probabilistic Matrix Factorization. In Proceedings of the 20th International Conference on Neural Information Processing Systems (NIPS'07), J. C. Platt, D. Koller, Y. Singer, and S. T. Roweis (Eds.). Curran Associates Inc., USA, 1257-1264.

[5] Paterek, Arkadiusz. “Improving regularized singular value decomposition for collaborative filtering.” (2007).

License

This code is available under the Eclipse Public License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matrix-completion-0.0.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matrix_completion-0.0.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file matrix-completion-0.0.1.tar.gz.

File metadata

  • Download URL: matrix-completion-0.0.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for matrix-completion-0.0.1.tar.gz
Algorithm Hash digest
SHA256 df455d8b22bba206e6006d726b62e172ae72821bde19d3f96d2d48ec01c2d4c9
MD5 579129ca28de148431dd50abd6d2544a
BLAKE2b-256 9ce31f55312c34ed8aa1e2e58ddd9d4af463906fad5593ef04ad7e69123e8a9d

See more details on using hashes here.

File details

Details for the file matrix_completion-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: matrix_completion-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for matrix_completion-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80b6c0e9057cd84558152e625aa8dfb806e8a7ff67cf4557e514bb9a024b7ff8
MD5 7372bc7652b9265efbaf770870416167
BLAKE2b-256 0393197f775ae568d06a9aa35928f828be09444618db7453d5b094d8730224e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page