Skip to content

Instantly share code, notes, and snippets.

@spikar
Created June 23, 2019 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spikar/3f66df482592278d09de86fee7cf402c to your computer and use it in GitHub Desktop.
Save spikar/3f66df482592278d09de86fee7cf402c to your computer and use it in GitHub Desktop.
# TODO: Import GaussianMixture
from sklearn.mixture import GaussianMixture
# TODO: Create an instance of Gaussian Mixture with 3 components
gmm = GaussianMixture(n_components=3).fit(X)
# TODO: fit the dataset
gmm = gmm.fit(X)
# TODO: predict the clustering labels for the dataset
pred_gmm = gmm.predict(X)
# Plot the clusters
plt.figure( figsize=(16,12))
plt.scatter(X[:,0], X[:,1], c=pred_gmm, edgecolor='black', lw=1.5, s=100, cmap=plt.get_cmap('viridis'))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment