Created
February 23, 2019 18:09
-
-
Save DFoly/75db5fa932b27814427a7d4b7b2ef0d2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| model = GMM(3, n_runs = 30) | |
| fitted_values = model.fit(Y_sklearn) | |
| predicted_values = model.predict(Y_sklearn) | |
| # # compute centers as point of highest density of distribution | |
| centers = np.zeros((3,2)) | |
| for i in range(model.C): | |
| density = mvn(cov=model.sigma[i], mean=model.mu[i]).logpdf(Y_sklearn) | |
| centers[i, :] = Y_sklearn[np.argmax(density)] | |
| plt.figure(figsize = (10,8)) | |
| plt.scatter(Y_sklearn[:, 0], Y_sklearn[:, 1],c=predicted_values ,s=50, cmap='viridis', zorder=1) | |
| plt.scatter(centers[:, 0], centers[:, 1],c='black', s=300, alpha=0.5, zorder=2); | |
| w_factor = 0.2 / model.pi.max() | |
| for pos, covar, w in zip(model.mu, model.sigma, model.pi): | |
| draw_ellipse(pos, covar, alpha = w) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment