This repository provides tools and algorithms for the estimation of mixture models for mixed-type data. The algorithms jointly estimate the model parameters and the number of classes in the model.
This repository corresponds to the implementation of the paper 📄 Solange Pruilh, Stéphanie Allassonnière. Dynamic Expectation-Maximization algorithms for Mixed-type Data. 2024..
The code was tested on Python 3.12.4.
With uv (recommended — installs Python and all dependencies in one step):
pip install uv # install uv once, globally
uv sync # creates .venv/ and installs all dependencies
uv run python # run any command inside the environmentWith conda (alternative):
conda create -n DEM_MD --file requirements.txt
conda activate DEM_MD
pip install -e .import numpy as np
from dem_md import GaussianDEMMD
# Continuous-only data
X = np.random.randn(200, 4)
model = GaussianDEMMD()
labels = model.fit_predict(X)
# Mixed data (continuous + one Bernoulli discrete feature)
X_mixed = np.hstack([np.random.randn(200, 3), np.random.randint(0, 2, (200, 1))])
model_mixed = GaussianDEMMD(
type_discrete_features=["Bernoulli"],
index_discrete_features=[np.array([3])],
)
labels_mixed = model_mixed.fit_predict(X_mixed)See the tutorial notebook for detailed experiments on different use cases.
Several classes are provided, corresponding to DEM-MD algorithms to estimate different mixture models.
DEM_MD_gaussian.py,DEM_MD_student.pyandDEM_MD_sal.pycontain classes to estimate mixture models with respectively Gaussian (GaussianDEMMD), Student (StudentDEMMD) and Shifted Asymmetric Laplace (SALDEMMD) distributions.- These three DEM-MD classes are based on
base_DEM_MD.py,base_MD.pyandbase.pywhich are parent classes. utilsfolder contains several files with tool functions:sampling.pyfor sampling datasets,calculation.pyfor miscellaneous computations, andvalidation.pyfor input validation.history.pycontains theHistoricclass, which is directly instantiated into DEM-MD classes.Notations.mddocuments the variable naming conventions used throughout the codebase.
@unpublished{pruilh2024demmd,
title = {Dynamic Expectation-Maximization algorithms for Mixed-type Data},
author = {Pruilh, Solange and Allassonni{\`e}re, St{\'e}phanie},
year = {2024},
note = {Preprint},
url = {https://hal.science/hal-04510689},
}