Introduktion till k-means

Klusteranalys i R

Dmitriy (Dima) Gorenshteyn

Lead Data Scientist, Memorial Sloan Kettering Cancer Center

Klusteranalys i R

Klusteranalys i R

Klusteranalys i R

Klusteranalys i R

Klusteranalys i R

Klusteranalys i R

Klusteranalys i R

Klusteranalys i R

Klusteranalys i R

Klusteranalys i R

kmeans()

print(lineup)
       x     y
 1    -1     1
 2    -2    -3
 3     8     6
 4     7    -8
 ...  ...   ...
model <- kmeans(lineup, centers = 2)
Klusteranalys i R

Tilldela kluster

print(model$cluster)
1 1 2 2 1 1 1 2 2 2 1 2
lineup_clustered <- mutate(lineup, cluster = model$cluster)
print(lineup_clustered)
       x     y cluster
   <dbl> <dbl>   <int>
 1    -1     1       1
 2    -2    -3       1
 3     8     6       2
 4     7    -8       2
 ...  ...  ...     ...
Klusteranalys i R

Nu kör vi en övning!

Klusteranalys i R

Preparing Video For Download...