MBMM (Multivariate Beta Mixture Model) Documentationο
π Overviewο
MBMM is a probabilistic soft clustering algorithm using mixtures of multivariate Beta distributions. Each feature is modeled independently with a Beta distribution. It is especially effective when features are constrained to the range (0,1).
βοΈ Class Definitionο
Class Name: MBMM
This class implements the EM algorithm for estimating parameters of Beta mixtures across multiple dimensions.
class MBMM:
def __init__(self, n_components: int = 3, max_iter: int = 100, tol: float = 1e-5):
...
π Parametersο
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
3 |
Number of clusters/components in the mixture |
|
int |
100 |
Maximum number of iterations in the EM algorithm |
|
float |
1e-5 |
Convergence threshold on log-likelihood |
π Usage Examplesο
from soft_clustering._mbmm._mbmm import MBMM
import numpy as np
# Create synthetic beta-distributed data
X1 = np.random.beta(2, 5, size=(50, 2))
X2 = np.random.beta(5, 2, size=(50, 2))
X = np.vstack([X1, X2])
model = MBMM(n_components=2, max_iter=100)
model.fit(X)
print("Labels:", model.predict())
print("Memberships:", model.predict_proba())
π₯ Input / π€ Outputο
Input to
fit(X):X (np.ndarray): Input data (N x D), all features must be in the range (0,1)
Returns:
Membership probabilities:
predict_proba()β array of shape (N x K)Hard labels:
predict()β array of shape (N,)
π οΈ Methodsο
fit(X): Fits the MBMM model using EM algorithmpredict_proba(): Returns the membership probability matrixpredict(): Returns hard cluster labels
π Implementation Notesο
Each dimension is modeled independently with a Beta distribution
Parameters estimated via method of moments in M-step
Log-likelihood used for convergence checking
Input data must be scaled to (0,1)
π Referenceο
Kim, K., & Tewari, A. (2024). Multivariate Beta Mixture Model: Probabilistic Clustering with Flexible Cluster Shapes.