Qu

silhouette_score

Builtin index · Statistics & ML

silhouette_score(X, labels)

Input: X, labels · Output: no output

What it is

The mean of silhouette(X, labels), a number in [-1, 1]; the usual single figure for choosing the number of clusters k (largest wins). Same arguments and errors as silhouette.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
silhouette_score(X, labels)
X numbernot documented yet
labels numbernot documented yet
not documented yetSame arguments and errors as silhouette.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

G = vstack(randn(40, 2, seed = 31) + 4,
           randn(40, 2, seed = 32) - 4,
           randn(40, 2, seed = 33))
for k = 2:5
    s = silhouette_score(G, kmeans(G, k, seed = 5))
    print("k = {k}: silhouette = {round(s, 3)}")
end for
output
k = 2: silhouette = 0.558
k = 3: silhouette = 0.692
k = 4: silhouette = 0.559
k = 5: silhouette = 0.539

from statistics-ml