October 2017
Beginner to intermediate
572 pages
26h 1m
English
Perform the following steps to find the optimum number of clusters for the k-means clustering:
> nk = 2:10
> set.seed(22)
> WSS = sapply(nk, function(k) {
+ kmeans(customer, centers=k)$tot.withinss
+ })
> WSS
Output
[1] 123.49224 88.07028 61.34890 48.76431 47.20813
[6] 45.48114 29.58014 28.87519 23.21331
> plot(nk, WSS, type="l", xlab= "number of k", ylab="within sum of squares")

Read now
Unlock full access