Created
June 23, 2019 10:15
-
-
Save spikar/3f66df482592278d09de86fee7cf402c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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