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 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file med_magma-1.0.1.tar.gz.
File metadata
- Download URL: med_magma-1.0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2de3f9b8e3224993cef5ea057f7ce758ac938e8d106d37a85867396e5c90329e
|
|
| MD5 |
cf30616085205a29ff7886a16a56107f
|
|
| BLAKE2b-256 |
bebc7225201b422ee7fb0bed7198695c62e57f617682ec2adf741518b640d3ba
|
File details
Details for the file med_magma-1.0.1-py3-none-any.whl.
File metadata
- Download URL: med_magma-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4548f805597ba57d6f61326acb28b19abf0ea4c389a710e6f6f035e2def7b33b
|
|
| MD5 |
ee6cca2bfeabe686dfa0d65708a03a9b
|
|
| BLAKE2b-256 |
248dbf45df89ae99f18a1c51ce5f184ce0ebe3293939b1115e7084239f8d955a
|