MeDIL

MeDIL is a Python package for causal factor analysis, using the measurement dependence inducing latent (MeDIL) causal model framework [MGW20]. The package is under active development—see the develop branch of the repository on GitLab or its Github mirror.

https://gitlab.com/alex-markham/medil/badges/develop/coverage.svg
Version:

2.0.0

Date:

Jul 08, 2026

Installation:

You can install the package from PyPI with the command pip install medil.

Features:

  • scikit-learn-style API

  • estimation of sparse causal factor structure and loadings in the linear Gaussian setting or more generally using a deep generative model [MLAS23], supporting both continuous and categorical measurements

  • \(\ell_0\)-penalized maximum likelihood estimation (BIC score-based search) for minimum MeDIL causal graphs in the linear Gaussian setting, as well as nonparametric constraint-based search using distance covariance, xi correlation, or g-test (for discrete data)

  • random generation of and sampling from linear Gaussian and deep generative causal factor models

  • exact search for minimum edge clique cover (ECC) [GGfN09] as well as polynomial time heuristic using the one-pure-child assumption [MLAS23]

  • reproducible experiments from [MLAS23] via a Snakemake workflow in src/expt/ — see the experiment README

Design principles:

  • core functionality (linear Gaussian setting) with minimal dependencies: NumPy, SciPy, and scikit-learn

  • optional PyTorch dependency (pip install medil[ncfa]) for NeuroCausalFactorAnalysis and deep generative causal mechanisms

Further documentation:

Indices and tables