Guest User

Untitled

a guest
Oct 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. findWSS <- function(data) {
  2. print(paste("[TRACER] Finding WSS.."))
  3.  
  4. start <- Sys.time()
  5. wss <- (nrow(data)-1)*sum(apply(data,2,var))
  6.  
  7. for (i in 2:length(unique(data))) {
  8. wss[i] <- sum(kmeans(data, centers=i)$withinss)
  9. }
  10. plot(1:length(unique(data)), wss, type="b", xlab="Number of Clusters", ylab="Within groups sum of squares")
  11.  
  12. end <- Sys.time()
  13. print(paste("[TIMER] Finding WSS:", difftime(end, start), "secs"))
  14. }
Add Comment
Please, Sign In to add comment