How use visualize Gaussian mixture model's clusters for multi dimensional data in Scikit?
Asked Answered
S

0

7

I have seen the Scikit-Learn example of Gaussian mixture for clustering. In this example (and other examples of this model), it looks the data always has two dimensions:

plt.scatter(X[:, 0], X[:, 1], s=10, color=colors[y_pred])

I use the following script ( X actully has more than 2 columns),

clf = mixture.GaussianMixture(n_components=2, covariance_type='full')
clf.fit(X)
y_pred = clf.predict(X)
colors = np.array(list(islice(cycle(['#377eb8', '#ff7f00', '#4daf4a',
                                 '#f781bf', '#a65628', '#984ea3',
                                 '#999999', '#e41a1c', '#dede00']),
                          int(max(y_pred) + 1))))
plt.scatter(X[:, 0], X[:, 1], s=10, color=colors[y_pred])
plt.show()

How can I visualize the clusters and data points?

Stepfather answered 3/11, 2017 at 16:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.