Skip to main content

CSMC

CSMC is a Python library for performing column subset selection in matrix completion tasks. It provides an implementation of the CSSMC method, which aims to complete missing entries in a matrix using a subset of columns.

Columns Selected Matrix Completion (CSMC) is a two-stage approach for low-rank matrix recovery. In the first stage, CSMC samples columns of the input matrix and recovers a smaller column submatrix. In the second stage, it solves a least squares problem to reconstruct the whole matrix.

Alt text

CSMC supports numpy arrays and pytorch tensors.

Installation

You can install CSMC using pip:

pip install -i  csmc

Usage

  1. Generate random data
import numpy as np
import random 

n_rows = 50
n_cols = 250
rank = 3

x = np.random.default_rng().normal(size=(n_rows, rank)) 
y = np.random.default_rng().normal(size=(rank, n_cols)) 
M = np.dot(x, y)

M_incomplete = np.copy(M)
num_missing_elements = int(0.7 * M.size)
indices_to_zero = random.sample(range(M.size), k=num_missing_elements)
rows, cols = np.unravel_index(indices_to_zero, M.shape)
M_incomplete[rows, cols] = np.nan
  1. Fill with CSNN algorithm
from csmc import CSMC
solver = CSMC(M_incomplete, col_number=100)
M_filled = solver.fit_transform(M_incomplete)
  1. Fill with Nuclear Norm Minimization with SDP (NN algorithm)
from csmc import NuclearNormMin
solver = NuclearNormMin(M_incomplete)
M_filled = solver.fit_transform(M_incomplete, np.isnan(M_incomplete))
  1. Fill with Frank-Wolfe (Conditional Gradient Method)
from csmc import CGM
solver = CGM(M_incomplete)
M_filled = solver.fit_transform(M_incomplete, np.isnan(M_incomplete))

Algorithms

Examples

Configuration

To adjust the number of threads used for intraop parallelism on CPU, modify variable:

NUM_THREADS = 8

in settings.py

Citation

Krajewska, A., Niewiadomska-Szynkiewicz E. (2024). Randomized Approach to Matrix Completion: Applications in Recommendation Systems and Image Inpainting.

Krajewska, A. , Niewiadomska-Szynkiewicz E., "Efficient Data Completion and Augmentation." 2024 IEEE 11th International Conference on Data Science and Advanced Analytics (DSAA). IEEE, 2024.

Metadata

Release files for csmc 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csmc 2.0.0
File Size Uploaded Provenance Actions
csmc-2.0.0.tar.gz 20.9 kB Without provenance Details for csmc-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for csmc 2.0.0
File Interpreter ABI Platform Actions
csmc-2.0.0-py3-none-any.whl Python 3 none any Details for csmc-2.0.0-py3-none-any.whl

Total release size: 40.6 kB

Release files / csmc-2.0.0.tar.gz

Download URL csmc-2.0.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
33e694034d416beeeff2da6683dd09b85e770ce3346490c509aceff63520062c
BLAKE2b-256 checksum
How to use checksums
431eb1906e69ddc23b1b0214c48bf5c742352995452ee4d8cc9de42b345cfd01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.12 Linux/6.8.0-85-generic

Release files / csmc-2.0.0-py3-none-any.whl

Download URL csmc-2.0.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f050d4c65606610e1a8f70667b540acc24bbf61edb7195cf527fa39b58e74bb4
BLAKE2b-256 checksum
How to use checksums
bd1399cbb78a2c1b8ab1b1f646ee3e0cd7d5932e990cd002944893bff2f5b0e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.12 Linux/6.8.0-85-generic

Security for csmc 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page