
k-means clustering via Lloyd's algorithm, k-means++ seeded (Geron Ch 8, morie.fn hmkmn)
Source:R/geron_w4b_native.R
morie_geron_kmeans.Rdk-means clustering via Lloyd's algorithm, k-means++ seeded (Geron Ch 8, morie.fn hmkmn)
Examples
morie_geron_kmeans(X = c(1, 2, 3, 4, 5, 6, 7, 8), n_clusters = 5L)
#> $labels
#> [1] 0 0 0 2 3 1 4 4
#>
#> $centers
#> [,1]
#> [1,] 2.0
#> [2,] 6.0
#> [3,] 4.0
#> [4,] 5.0
#> [5,] 7.5
#>
#> $inertia
#> [1] 2.5
#>
#> $n_iter
#> [1] 2
#>
#> $distances
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1 5 3 4 6.5
#> [2,] 0 4 2 3 5.5
#> [3,] 1 3 1 2 4.5
#> [4,] 2 2 0 1 3.5
#> [5,] 3 1 1 0 2.5
#> [6,] 4 0 2 1 1.5
#> [7,] 5 1 3 2 0.5
#> [8,] 6 2 4 3 0.5
#>
#> $counts
#> [1] 3 1 1 1 2
#>
#> $estimate
#> [1] 2.5
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "k-means (Lloyd's algorithm, k-means++ seeded)"
#>