Advertisement
Guest User

Untitled

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