_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › K-MedoidsClustering

Contents

1 k-means k-medioids 谿伎
2
3 豕 k襯 谿城 るジ 覦覯
4 谿瑚襭


1 k-means k-medioids 谿伎 #

  • k-means : 譴朱 ′
  • k-medioids: れ 螳 譴朱 ′

2 #

一危
n = 100
g = 6 
set.seed(g)
d <- data.frame(x = unlist(lapply(1:g, function(i) rnorm(n/g, runif(1)*i^2))), 
                y = unlist(lapply(1:g, function(i) rnorm(n/g, runif(1)*i^2))))

library(fpc)
library("cluster")
#豕 k螳 谿場

#k <- pamk(d)$nc
k <- pamk(d)$nc+1
cl <- pam(d, k)
result <- data.frame(d, clusterid=cl$clustering)

par(mfrow=c(1,2))

plot(d, cex=0.2)
plot(d, cex=0.2)
colour <- c("red", "blue", "black", "green")
points(result$x, result$y, col=c(colour[result$clusterid]))

par(mfrow=c(1,1))
kmedoids.png


3 豕 k襯 谿城 るジ 覦覯 #

谿瑚: http://stackoverflow.com/questions/15376075/cluster-analysis-in-r-determine-the-optimal-number-of-clusters
n = 100
g = 6 
set.seed(g)
d <- data.frame(x = unlist(lapply(1:g, function(i) rnorm(n/g, runif(1)*i^2))), 
                y = unlist(lapply(1:g, function(i) rnorm(n/g, runif(1)*i^2))))

sim <- clusGap(d, FUN = pam, K.max = 20, B = 100)
k <- with(sim, maxSE(Tab[,"gap"],Tab[,"SE.sim"]))
plot(sim)
abline(v=k, lty=2, col="blue")

k.png

k-means
wss <- (nrow(d)-1)*sum(apply(d,2,var))
for (i in 2:15) wss[i] <- sum(kmeans(d, centers=i)$withinss)
plot(1:15, wss, type="b", xlab="Number of Clusters", ylab="Within groups sum of squares")
k001.png
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

螳襦企 覓危 殊 伎る 蟆 るジ 襦 殊 蠍壱螳 蠍 蟆企.