milia.cluster.models.gmm#

Gaussian mixture model.

Classes

GMM([n_clusters, covariance_type, random_state])

Probabilistic clustering with a Gaussian mixture.

GMMConfig(*[, name, kind, space, ...])

Validated hyperparameters of the Gaussian mixture clusterer.

class milia.cluster.models.gmm.GMM(n_clusters=3, covariance_type='full', random_state=0)#

Bases: BaseClusterer

Probabilistic clustering with a Gaussian mixture.

Parameters:
  • n_clusters (int) – Number of mixture components.

  • covariance_type (str) – "full", "tied", "diag" or "spherical".

  • random_state (int | None) – Seed.

Examples

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> X = np.repeat(np.array([[0.0, 0.0], [6.0, 6.0], [0.0, 6.0]]), 20, axis=0) + rng.normal(
...     scale=0.4, size=(60, 2)
... )
>>> GMM(n_clusters=3).fit(X).n_clusters_
3
predict_proba(X)#

Posterior membership probability of each row in each component.

Parameters:

X (ndarray) – Rows.

Return type:

ndarray

Returns:

Array of shape (n, n_clusters); rows sum to one.

class milia.cluster.models.gmm.GMMConfig(*, name='gmm', kind='clusterer', space=SearchSpace(n_clusters=(2, 12), covariance_type=['full', 'diag']), n_clusters=3, covariance_type='full', random_state=0)#

Bases: BaseModelConfig

Validated hyperparameters of the Gaussian mixture clusterer.

Fields mirror GMM’s constructor; space is the default Optuna search space. Build the clusterer with make("clusterer", "gmm", ...) or GMM(**config.params()).

Examples

>>> GMMConfig().name
'gmm'