ClusterSilhouette: Mean Silhouette Width

View source: R/ClusterSilhouette.R

ClusterSilhouetteR Documentation

Mean Silhouette Width

Description

Mean Silhouette Width [Rousseeuw, 1987] evaluates a hard partition without a reference classification. Mean silhouette width; larger values are better.

Usage

ClusterSilhouette(Cls, DataOrDistances, DistanceMethod = "euclidean",
                             Silent = TRUE, ...)

Arguments

Cls

Vector of length n containing arbitrary numeric, character, or factor cluster labels. Missing labels and non-finite numeric labels are not allowed. Rows and labels are matched by position. Zero is an ordinary cluster label; remove noise observations explicitly if they should not be evaluated.

DataOrDistances

Finite numeric data matrix or data frame with n rows, a symmetric n by n dissimilarity matrix with non-negative entries and a zero diagonal, or a dist object. Matrices are recognized as dissimilarities by IsDissimilarity. A square raw-data matrix satisfying that test is therefore interpreted as distances. Each unordered pair is counted once, without self-pairs.

DistanceMethod

Distance method for feature data, passed to parallelDist::parDist() or stats::dist() if parallelDist is unavailable. Ignored for precomputed dissimilarities. Default: "euclidean".

Silent

Logical scalar. Suppresses the progress message for distance calculation when TRUE; warnings and missing-package messages remain.

...

Further arguments for parallelDist::parDist() or its stats::dist() fallback. Ignored for precomputed dissimilarities.

Details

ClusterSilhouette wraps silhouette and returns the observation-weighted mean silhouette width. A singleton has width zero. At least two and at most n-1 clusters are required.

Malformed inputs cause an error. Undefined partitions produce a warning and return NaN. A missing optional cluster package gives NaN, a message, and an explanatory string in Object.

Pairwise distance storage is quadratic in the number of observations. No observations are subsampled.

This function is also called by ClusterNoEstimation. The standalone function evaluates one given partition without selecting a number of clusters.

Value

List of

Silhouette

Mean silhouette width; larger values are better.

Object

The silhouette object with a ClusterLabels attribute mapping its consecutive labels to the input labels. Undefined partitions return NULL; a missing cluster package returns an explanatory string.

Author(s)

Michael Thrun

References

[Rousseeuw, 1987] Rousseeuw, P. J.: Silhouettes: A graphical aid to the interpretation and validation of cluster analysis, Journal of Computational and Applied Mathematics, Vol. 20, pp. 53-65, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/0377-0427(87)90125-7")}, 1987.

See Also

ClusterNoEstimation, ClusterDunnIndex, ClusterDaviesBouldinIndex

Examples

Data = matrix(c(0, 1, 2, 10, 11, 12), ncol = 1)
Cls = rep(c(10, 20), each = 3)
if (requireNamespace("cluster", quietly = TRUE)) {
  V = ClusterSilhouette(Cls, Data)
  V$Silhouette
}

FCPS documentation built on Nov. 28, 2026, 9:08 a.m.