MED-MAGMA
The code to run MED-MAGMA is contained in MED_MAGMA.py. Below is a minimal example of how to run it:
from MED_MAGMA import quotient, EM_algorithm, sparse_quotient
# Let X be your dataset
X: np.ndarray
# Map it to the quotient space
# If X contains zeros, use `sparse_quotient` instead
Y = quotient(X)
# Run our algorithm; EM_results contains the learned graphs, magnitudes contains the learned "r" values if those are of interest
EM_results, magnitudes = EM_algorithm(Y, max_iter = 100, verbose=False, very_verbose=False, stop_tol=1e-7, regularization=0)
In the paper we mentioned briefly that one could turn the $\mathbf{z}^*$ estimation portion of our algorithm into a convex problem by using a simplex constraint rather than our geometric mean constraint (but that this would introduce bias into the algorithm that made it unsuitable). If you wish to check this out for yourself, we have MED_MAGMA_simplex.py which has the same API as MED_MAGMA.py. What you'll find is that it works for synthetic data, but on most real datasets it just learns an essentially constant matrix (which manifests from the aforementioned bias towards the simplex's corners - which dominates when signal-to-noise is lower).
Package
This algorithm is available on PyPI https://pypi.org/project/MED-MAGMA/1.0.0/.
Dependencies
This code was written in Python 3.13 with NumPy 2.3 and SciPy 1.16.
The exact environment used to run the paper's experiments is given in environment.yaml, but to just run our algorithm only Python, NumPy, and SciPy are required. (MED_MAGAM_simplex requires cvxpy as well).
Paper
The figures for the paper are generated in the following:
- Figure 1 (Tail Dependence):
median-data-experiment.ipynb - Figure 2 (Synthetic Validation):
synthetic-experiments-paper.ipynb - Figure 3 (Real Validation):
all-real-data-all.ipynb - Figure 4 (UMAP):
median-data-experiment.ipynb - Figure 5 (Supplementary, Synthetic Validation):
synthetic-experiments-paper.ipynb - Figure 6 (Supplementary, Effect of Sparsity):
synthetic-experiments-paper.ipynb
All further empirical values given in the paper are from median-data-experiment.ipynb, except for robustness using Robin; this is computed in robin-on-median.rmd (an R markdown file).
The conda environment used to generate these results is given in environment.yaml.
Metadata
Release files for MED-MAGMA 1.0.1
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 |
|---|---|---|---|---|
| med_magma-1.0.1.tar.gz | 1.1 MB | Without provenance | Details for med_magma-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| med_magma-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for med_magma-1.0.1-py3-none-any.whl |
Total release size: 1.1 MB
Release files / med_magma-1.0.1.tar.gz
| Download URL | med_magma-1.0.1.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2de3f9b8e3224993cef5ea057f7ce758ac938e8d106d37a85867396e5c90329e
|
|
BLAKE2b-256 checksum How to use checksums |
bebc7225201b422ee7fb0bed7198695c62e57f617682ec2adf741518b640d3ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / med_magma-1.0.1-py3-none-any.whl
| Download URL | med_magma-1.0.1-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4548f805597ba57d6f61326acb28b19abf0ea4c389a710e6f6f035e2def7b33b
|
|
BLAKE2b-256 checksum How to use checksums |
248dbf45df89ae99f18a1c51ce5f184ce0ebe3293939b1115e7084239f8d955a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for MED-MAGMA 1.0.1
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.