Untitled
unknown
plain_text
a year ago
462 B
5
Indexable
from sklearn.mixture import GaussianMixture
import numpy as np
lowest_bic = np.infty
best_gmm = None
n_components_range = range(1, 20) # try different numbers
for n in n_components_range:
gmm = GaussianMixture(n_components=n, covariance_type='full', random_state=42)
gmm.fit(embeddings)
bic = gmm.bic(embeddings)
if bic < lowest_bic:
lowest_bic = bic
best_gmm = gmm
cluster_labels = best_gmm.predict(embeddings)
Editor is loading...
Leave a Comment