Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to visualize kmeans clustering on multidimensional data

I am using kmeans clustering algorithm on mnist dataset and want to visualize the plots after clustering. So far I did this

from mnist import MNIST

mndata = MNIST('Datasets')
X_train, y_train = mndata.load_training()

#do the clustering
k_means = cluster.KMeans(n_clusters=len(np.unique(y_train)))
k_means.fit(X_train)
labels = k_means.labels_

So, I now have 10 clusters representing 0 to 9. How can I visualize these clusters?

like image 898
asdlfkjlkj Avatar asked Oct 20 '17 07:10

asdlfkjlkj


1 Answers

You can visualise multi-dimensional clustering using pandas plotting tool parallel_coordinates.

predict = k_means.predict(data)
data['cluster'] = predict
pandas.tools.plotting.parallel_coordinates(data, 'cluster')
like image 66
Charlotte Rogers Avatar answered Nov 13 '22 09:11

Charlotte Rogers