0

I am having some issues with plotting my clusters in R. I am using Kmeans as a way of compressing my dataset. My dataset is already labeled into 10 classes, so i already know what class each datapoint belongs to. Is it possible to visualize how each datapoint is sorted within each cluster. Such that I could make some form of conclusion of the class distribution within each cluster.

I tried using table

table(data$labels[kmeans_output$clusterr==1])

which outputs

C0  C1  C2  C3  C4  C5  C6  C7  C8  C9 
  4   0   0   1   0  13   0   0 245   0 

Which i think is the class distribution of cluster 1.

Is possible to visualize this for all the clusters?

enter image description here

Lamda
  • 914
  • 3
  • 13
  • 39

1 Answers1

1

An example using iris as your example is not reproducible. Is this what you're looking for?

km <- kmeans(iris[, 1:2], 3)
plot(iris[, 1:2], col=km$cluster)
table(iris$Species, km$cluster)
Community
  • 1
  • 1
Vincent Bonhomme
  • 7,235
  • 2
  • 27
  • 38