Skip to main content

A python package containing several robust algorithms for matrix decomposition, rank estimation and relevant analysis.

Project description

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

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 20 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 -

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

decompy-1.1.0.tar.gz (55.3 kB view details)

Uploaded Source

Built Distribution

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

decompy-1.1.0-py3-none-any.whl (73.5 kB view details)

Uploaded Python 3

File details

Details for the file decompy-1.1.0.tar.gz.

File metadata

  • Download URL: decompy-1.1.0.tar.gz
  • Upload date:
  • Size: 55.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.2

File hashes

Hashes for decompy-1.1.0.tar.gz
Algorithm Hash digest
SHA256 02776669042db4938047e872bc7b377733e326aafdeae4c51c11bdd0182f0b9a
MD5 2e3b9311c879504b36543a38ab2aea26
BLAKE2b-256 59e0c842ff980fd389326ed97856847ba248a21ab94e03b70278b822e20989fa

See more details on using hashes here.

File details

Details for the file decompy-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: decompy-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 73.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.2

File hashes

Hashes for decompy-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e08db5db97902d4117a60bffc10c9a573e9c6cd528eb36cb30f91ac0c0e210f
MD5 2249fcc0ca50eb1c36b03401daf1dcf3
BLAKE2b-256 434ff93a205ec453f33dec1bb9c988c99a01daff7df2344fd68d1689063cf5b8

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