Skip to main content

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)

Source distribution for MED-MAGMA 1.0.1
File Size Uploaded
med_magma-1.0.1.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for MED-MAGMA 1.0.1
File Interpreter ABI Platform
med_magma-1.0.1-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.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