Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # As the initial centroids are defined randomly,
- # we define a seed for purposes of reprodutability
- set.seed(123)
- # Let's remove the column with the mammals' names, so it won't be used in the clustering
- input <- all.mammals.milk.1956[,2:6]
- # The nstart parameter indicates that we want the algorithm to be executed 20 times.
- # This number is not the number of iterations, it is like calling the function 20 times and then
- # the execution with lower variance within the groups will be selected as the final result.
- kmeans(input, centers = 3, nstart = 20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement