Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- setwd("C:\\Users\\Nikita\\Downloads\\r_lab3")
- x <- read.csv(file="clustering_group_10.csv", header = FALSE)
- plot(x, type="p", col="red")
- #алгоритм k-means
- kmeans.model = kmeans(x, 2, iter.max = 100, nstart = 1, algorithm = "Lloyd")
- #Нахождение модели
- kmeans.model$tot.withinss
- kmeans.model$centers
- #Распечатка результатов
- for (i in 1:1000){
- y1<-x[i,1]
- y2<-x[i,2]
- if (kmeans.model$cluster[i]==1)
- points(y1,y2,col="blue", type="p")
- else
- points(y1,y2,col="red", type="p")
- }
Advertisement
Add Comment
Please, Sign In to add comment