Bayesian Sparse Gaussian Mixture Model implementation in Python
Project description
Bayesian Sparse GMM
Bayesian Sparse Gaussian Mixture Model (GMM) implementation in Python.
This model employs a sparsity-inducing prior (e.g., a Dirichlet distribution with parameter $\alpha_0 < 1$) over mixture component weights to automatically determine/prune the number of active components.
Installation
To install the latest release:
pip install bayesian-sparse-gmm
Or for development (editable mode):
git clone https://github.com/Coalyx/bayesian-sparse-gmm.git
cd bayesian-sparse-gmm
pip install -e .
Quick Start
import numpy as np
from sklearn.datasets import make_blobs
from sklearn.preprocessing import StandardScaler
from bayesian_sparse_gmm import BayesianSparseGMM
# Append noise dimensions to true clusters to verify that the model successfully performs feature selection.
rng = np.random.default_rng(42)
X_clean, _ = make_blobs(n_samples=200, centers=3, n_features=2, cluster_std=0.5, random_state=42)
X_noise = rng.normal(loc=0.0, scale=1.0, size=(200, 8))
X = np.hstack([X_clean, X_noise])
# Standardize features to satisfy the zero-mean assumptions in the prior structure.
X = StandardScaler().fit_transform(X)
model = BayesianSparseGMM(
K_max=5,
n_iter=300,
burn_in=100,
lambda_0=10.0,
lambda_1=0.05,
random_state=42,
verbose=0
)
model.fit(X)
print(f"Number of active clusters: {model.n_clusters_}")
print(f"Selected informative features: {model.selected_features_}")
print(f"Feature inclusion probabilities: {model.feature_probabilities_.round(3)}")
labels = model.predict(X)
Development and Testing
Install development dependencies:
pip install -e ".[dev]"
Run tests using pytest:
pytest
Reference
@article{JMLR:v26:23-0142,
author = {Dapeng Yao and Fangzheng Xie and Yanxun Xu},
title = {Bayesian Sparse Gaussian Mixture Model for Clustering in High Dimensions},
journal = {Journal of Machine Learning Research},
year = {2025},
volume = {26},
number = {21},
pages = {1--50},
url = {http://jmlr.org/papers/v26/23-0142.html}
}
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 bayesian_sparse_gmm-0.1.0.tar.gz.
File metadata
- Download URL: bayesian_sparse_gmm-0.1.0.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38d2e85945c288814892824a4f2777e94f0305da8d2164a3264f6834d8cd4fdc
|
|
| MD5 |
008f1b4c75d0a7798d9086f3a8b78017
|
|
| BLAKE2b-256 |
9e3946e3d915ad134a5a674881587738e556bb6898f3e1124c81bfb11e40fe99
|
Provenance
The following attestation bundles were made for bayesian_sparse_gmm-0.1.0.tar.gz:
Publisher:
release.yml on Coalyx/bayesian-sparse-gmm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bayesian_sparse_gmm-0.1.0.tar.gz -
Subject digest:
38d2e85945c288814892824a4f2777e94f0305da8d2164a3264f6834d8cd4fdc - Sigstore transparency entry: 1721429924
- Sigstore integration time:
-
Permalink:
Coalyx/bayesian-sparse-gmm@a1d47f136b776606575b94ecf596e900f8f87ee7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Coalyx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a1d47f136b776606575b94ecf596e900f8f87ee7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bayesian_sparse_gmm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bayesian_sparse_gmm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8fdd50f999bc9cf9d53412428640d1e78deb77b77741fe19b58344fe452f6f4
|
|
| MD5 |
3449abbe28044e7f429462e63198712b
|
|
| BLAKE2b-256 |
6392ccc58f6f42a9f89c02a36a3db932b0f4cd162fe11be099cf0c2428c1d329
|
Provenance
The following attestation bundles were made for bayesian_sparse_gmm-0.1.0-py3-none-any.whl:
Publisher:
release.yml on Coalyx/bayesian-sparse-gmm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bayesian_sparse_gmm-0.1.0-py3-none-any.whl -
Subject digest:
b8fdd50f999bc9cf9d53412428640d1e78deb77b77741fe19b58344fe452f6f4 - Sigstore transparency entry: 1721430236
- Sigstore integration time:
-
Permalink:
Coalyx/bayesian-sparse-gmm@a1d47f136b776606575b94ecf596e900f8f87ee7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Coalyx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a1d47f136b776606575b94ecf596e900f8f87ee7 -
Trigger Event:
push
-
Statement type: