PyCorrelation
PyCorrelation is a Python package designed to handle symmetric and correlation matrices efficiently. It builds upon the concept of symmetric matrices to provide a class dedicated to correlation operations, ensuring values fall within the valid range $(-1,1)$, and automatically maintaining correlations of 1 on the diagonal.
Features
- A class ensuring symmetry in a matrix: $x_{i,j} = x_{j,i}$
- A class for managing correlation matrices with strict validation of correlation values.
- Methods to set, retrieve, and validate correlation pairs using user-friendly indexers.
Installation
To install PyCorrelation, you can clone the repository and use pip:
git clone https://github.com/SRKX/PyCorrelation.git
cd PyCorrelation
pip install .
Usage
Below is an example of how to use the package:
from PyCorrelation import CorrelationMatrix
# Initialize a CorrelationMatrix
correl_matrix = CorrelationMatrix(keys=['A', 'B', 'C'], frozen_keys=True)
# Set correlations
correl_matrix[('A', 'B')] = 0.5
correl_matrix[('B', 'C')] = -0.2
# Access correlation values
print(correl_matrix[('B', 'A')]) # Outputs: 0.5
# Check if a key pair is in the matrix
print(('A', 'B') in correl_matrix) # Outputs: True
Classes and Methods
SymmetricMatrix
This is the base class for symmetric matrices. It allows you to define and manipulate a matrix where elements are mirrored across the diagonal.
Public Methods
keys(): Returns the keys of the matrix.to_2d_dict(selected_keys=None): Converts the matrix into a 2D dictionary, extracting only the selected keys (or all if not specified).to_2d_array(ordered_keys): Converts the matrix into a 2D array representation, returning a list of lists where the indices follow the ordered of the input parameter.
CorrelationMatrix
This class extends SymmetricMatrix and is specialized for correlation matrices. It includes additional validation to ensure values are always in $(-1,1)$, and that identical keys always have a correlation of 1.
License
This project is licensed under the MIT License.
Metadata
Release files for pycorrelation 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pycorrelation-0.0.2.tar.gz | 8.2 kB | Without provenance | Details for pycorrelation-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycorrelation-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for pycorrelation-0.0.2-py3-none-any.whl |
Total release size: 15.4 kB
Release files / pycorrelation-0.0.2.tar.gz
| Download URL | pycorrelation-0.0.2.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a0dc6f00c950eca557ae91d2d11ae07c4e7a5b4975d6c04faac5e2fd66bd749
|
|
BLAKE2b-256 checksum How to use checksums |
b56e6145f3c78aab0e5d6d746b62bda78556f757384448c48b331de1e532b059
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.8
|
Release files / pycorrelation-0.0.2-py3-none-any.whl
| Download URL | pycorrelation-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
911ef46b536c05216a19e2e7e02e8d943e060e24e73575a32f92263c7d315135
|
|
BLAKE2b-256 checksum How to use checksums |
c144ba8bcce8f6aa6daf26b7ac6d06358e88dacc18d035eccaf605644b305c56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.8
|
Security for pycorrelation 0.0.2
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.