Professional Documents
Culture Documents
33
In class exercise #45:
Repeat the previous exercise using all 60 columns.
Solution:
x<-data[,1:60,]
fit<-kmeans(x, 2)
sum(fit$cluster*2-3==y)/length(y)
34
In class exercise #46:
Consider the one-dimensional data set given by
x<-c(1,2,3,5,6,7,8) (I left out 4 on purpose). Starting with
initial cluster center values of 1 and 2 carry out
algorithm 8.1 until convergence by hand for k=2
clusters.
35
In class exercise #47:
Repeat the previous exercise by writing a loop in R and
verify that the final answer is the same.
36