Make silhouette plot legible for k-means

青春壹個敷衍的年華 提交于 2019-12-23 10:56:36

问题


I am trying to make a silhouette plot for a k-means clustering, but the bars are almost invisble. How can I make this chart legible?

Example code:

require(cluster)

X <- EuStockMarkets
kmm <- kmeans(X, 8)

D <- daisy(X)
plot(silhouette(kmm$cluster, D), col=1:8)

Example output:


回答1:


To fix this, set the border to NA:

plot(silhouette(kmm$cluster, D), col=1:8, border=NA)




回答2:


Really new to R, so I might be on the wrong track. Could you specify the column colors? Something like:

require(cluster)

X <- EuStockMarkets
kmm <- kmeans(X, 8)

D <- daisy(X)
plot(silhouette(kmm$cluster, D), col = c("blue","red","purple","green","black","pink","peach","orange")

I just learned that colors() shows the color options in R.

The idea above isn't a complete solution, as I'm not sure how to select columns 1 through 8 AND select colors for them. Plus, I'm sure there's a way for R to show the clusters in different colors automatically.



来源:https://stackoverflow.com/questions/32570693/make-silhouette-plot-legible-for-k-means

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!