Skip to content

Instantly share code, notes, and snippets.

@a-agmon
Last active April 15, 2021 07:38
Show Gist options
  • Save a-agmon/55d17f14dc2b5f2beb68e3e422d2cb09 to your computer and use it in GitHub Desktop.
Save a-agmon/55d17f14dc2b5f2beb68e3e422d2cb09 to your computer and use it in GitHub Desktop.
from sklearn.mixture import GaussianMixture as GMM
def cluster_gmm(matrix, k=4):
gmm_model = GMM(k, covariance_type='full', random_state=0, n_init=10)
gmm_model.fit(matrix)
gmm_labels = gmm_model.predict(matrix)
centers = gmm_model.means_
return gmm_model, gmm_labels, centers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment