Skip to contents

s_i = (b - a) / max(a, b) with a excluding the point itself; singleton clusters score 0.

Usage

morie_geron_silhouette_score(X, labels)

Arguments

X

(m, n) data.

labels

Cluster labels, at least 2 distinct and fewer than m.

Value

List with silhouette, per_sample, per_cluster, a, b.

Examples

set.seed(5)
X <- rbind(matrix(rnorm(20, 0), 10, 2), matrix(rnorm(20, 4), 10, 2))
lab <- rep(c(0L, 1L), each = 10)
morie_geron_silhouette_score(X, lab)
#> $silhouette
#> [1] 0.7101158
#> 
#> $per_sample
#>  [1] 0.6483523 0.6828304 0.7749070 0.8127190 0.6333656 0.8134189 0.8242582
#>  [8] 0.7332093 0.7897930 0.8126751 0.7702835 0.7842409 0.7096467 0.7816782
#> [15] 0.7707545 0.7170147 0.6627482 0.5279826 0.3563927 0.5960454
#> 
#> $per_cluster
#>         0         1 
#> 0.7525529 0.6676787 
#> 
#> $a
#>  [1] 2.225459 1.921330 1.796630 1.198818 2.243619 1.284829 1.245610 2.226461
#>  [9] 1.346995 1.203140 1.604750 1.635548 2.541281 1.639188 1.783305 1.895098
#> [17] 2.217206 2.915641 2.886479 2.221758
#> 
#> $b
#>  [1] 6.328663 6.057736 7.981723 6.401173 6.119500 6.886170 7.087728 8.345346
#>  [9] 6.407942 6.422748 6.985787 7.580436 8.752376 7.508127 7.779019 6.696810
#> [17] 6.574334 6.176978 4.484846 5.500019
#> 
#> $estimate
#> [1] 0.7101158
#> 
#> $n
#> [1] 20
#>