开发者

How to find coordinates of cluster in k-means

开发者 https://www.devze.com 2023-02-15 12:12 出处:网络
I\'m trying to use k-means clustering on a vector of开发者_运维知识库 type key-values. My question is, how do I set the coordinates of each element in the vector? Specifically the key-value pairs are

I'm trying to use k-means clustering on a vector of开发者_运维知识库 type key-values. My question is, how do I set the coordinates of each element in the vector? Specifically the key-value pairs are strings-floats. I need this to find later the center of the cluster.


Clustering algorithms typically only classify vertices to clusters. What you are looking for is a cluster-rendering algorithm which given a cluster partition of a graph renders the graph for visualization in a suitable way. I would say keep your cluster algorithm and visualization algorithms separate. Force-directed layout is a good simple cluster visualization algorithm.

And, lastly, here is a link to an implementation and another one.


K-means algorithms do generally compute centroids of clusters. For instance, in R's implementation:

n.clin <- 10
n.pop <- 100
clinicdat <- data.frame( x=runif(n.clin), y=runif(n.clin) )
popdat <- data.frame( x=runif(n.pop), y=runif(n.pop), pop=sample(1:5000, n.pop) )
plot(popdat$y~popdat$x, col="grey")
points(clinicdat$y~clinicdat$x, col="red")
km <- kmeans( subset(popdat,select=c(x,y)), n.clin )
points( fitted(km, method="centers"), col="green" )

How to find coordinates of cluster in k-means

0

精彩评论

暂无评论...
验证码 换一张
取 消