Skip to main content

An implementation of the matrix elliptical distribution multi-axis graphical modelling algorithm.

Project description

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 (TODO: link).

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.

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

med_magma-1.0.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

med_magma-1.0.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file med_magma-1.0.0.tar.gz.

File metadata

  • Download URL: med_magma-1.0.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for med_magma-1.0.0.tar.gz
Algorithm Hash digest
SHA256 da375931c32205271738bde71872b781be909f165e8940bc9ff2ed40b0e619db
MD5 13eabc10555d7ddfa57f7dc04b885d8c
BLAKE2b-256 901fd987877bd144bf010c21a902d2c4287c046826abf0d9dfe5dc41b8315875

See more details on using hashes here.

File details

Details for the file med_magma-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: med_magma-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for med_magma-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc6884c08111012136ee2c2d3ce809e357a340c90c53b7daa770ffd4442647d0
MD5 38f56efb2d1b4fe0d4c9ed927e6d65ec
BLAKE2b-256 6c1a1d20b2ddb05cfba3c3c4cc5930b9fd9dcd0bc9b601d9e71c2c479abcf70d

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