Skip to main content

decompy

decompy is a Python package containing several robust algorithms for matrix decomposition and analysis. The types of algorithms include

  • Robust PCA or SVD-based methods
  • Matrix completion methods
  • Robust matrix or tensor factorization methods.
  • Matrix rank estimation methods.

PyPI - Downloads decompy Tests Status Test Coverage Flake8

Features

  • Data decomposition using various methods
  • Support for sparse decomposition, low-rank approximation, and more
  • User-friendly API for easy integration into your projects
  • Extensive documentation and examples

Installation

You can install decompy using pip:

pip install decompy

Usage

Here's a simple example demonstrating how to use decompy for data decomposition:

import numpy as np
from decompy.matrix_factorization import RobustSVDDensityPowerDivergence

# Load your data
data = np.arange(100).reshape(20,5).astype(np.float64)

# Perform data decomposition
algo = RobustSVDDensityPowerDivergence(alpha = 0.5)
result = algo.decompose(data)

# Access the decomposed components
U, V = result.singular_vectors(type = "both")
S = result.singular_values()
low_rank_component = U @ S @ V.T
sparse_component = data - low_rank_component

print(low_rank_component)
print(sparse_component)

While the singular values are about 573 and 7.11 for this case (check the S variable), it can get highly affected if you use the simple SVD and change a single entry of the data matrix.

s2 = np.linalg.svd(data, compute_uv = False)
print(np.round(s2, 2))    # estimated by usual SVD
print(np.diag(np.round(S, 2)))    # estimated by robust SVD


data[1, 1] = 10000  # just change a single entry
s3 = np.linalg.svd(data, compute_uv = False)
print(np.round(s3, 2))   # usual SVD shoots up
s4 = algo.decompose(data).singular_values()
print(np.diag(np.round(s4, 2)))

You can find more example notebooks in the examples folder. For more detailed usage instructions, please refer to the documentation.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please create an issue or submit a pull request on the GitHub repository. For contributing developers, please refer to CONTRIBUTING.md file.

License

This project is licensed under the BSD 3-Clause License.

List of Algorithms available in the decompy library

Matrix Factorization Methods

Currently, there are 19 matrix factorization methods available in decompy, as follows:

Methods to be added (Coming soon)

Rank Estimation Methods

In rankmethods/penalized.py -

In rankmethods/cvrank.py -

In rankmethods/bayes.py -

News

v1.1.1

  • Release of unit test cases using pytest library.

v1.1.0

  • Bug fixes.
  • Release Documentation

v1.0.0

  • Major refactorization.
  • Added 15 more matrix factorization methods.
  • Added rank estimation methods.

v0.2.0

  • Added 4 matrix factorization methods.

v0.1.0

  • Initial release.

Metadata

Release files for decompy 1.1.1

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

Source distribution (sdist)

Source distribution for decompy 1.1.1
File Size Uploaded
decompy-1.1.1.tar.gz 56.4 kB Details

Built distribution (wheel)

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

Total release size: 128.2 kB

Release files / decompy-1.1.1.tar.gz

Download URL decompy-1.1.1.tar.gz
Size 56.4 kB
Tags Source
SHA-256 checksum
How to use checksums
336ef611ca5fc37ee99f7b13ab448064963cd0e5ae52fb72f0093561574a9056
BLAKE2b-256 checksum
How to use checksums
ce47ab9e553d4bbf09e3b5035d4f85d73c57bb182d375bf8fef0091c4ab6d84c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.2

Release files / decompy-1.1.1-py3-none-any.whl

Download URL decompy-1.1.1-py3-none-any.whl
Size 71.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6b22ffce4045af7aee76d3c7bb281694db533c827b6266141f58c15a51c2424
BLAKE2b-256 checksum
How to use checksums
9c8d0f375673271106c4430b97f7c5073f1e625d9896d0c240bd7d33bc0ff203
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.2

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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