Clustering

This module contains the implementation of the Gaussian Mixture Model (GMM)

GMM


source

select_n_components


def select_n_components(
    X, ks, n_init:int=5, max_iter:int=100, covariant_reg:float=1e-06, init_params:str='kmeans', random_seed:int=0
):

Try multiple K values and several initializations, return a summary dict.

Returns: results: dict keyed by K containing the best model and metrics (bic, aic, avg_log_lik, silhouette if possible).


source

GaussianMixture


def GaussianMixture(
    n_components, tol:float=1e-06, max_iter:int=100, reg_covar:float=1e-06, init_params:str='kmeans'
):

Gaussian Mixture Model with EM algorithm and K-means initialization.

Args:

n_components (int): Number of Gaussian components.
tol (float): Convergence tolerance.
max_iter (int): Maximum number of EM iterations.
reg_covar (float): Regularization for covariance matrix.
init_params (str): Initialization method ('kmeans' or 'random').

source

GaussianMixture.fit


def fit(
    X, key:ArrayImpl=Array([0, 0], dtype=uint32)
):

Fit the Gaussian mixture model using EM.

X : array (N, D) key : PRNGKey for random init