silinfo {ksharp}R Documentation

Compute info on silhouette widths

Description

This function provides information on how well each data point belongs to its cluster. For each query point, the function considers the average distance to other members of the same cluster and the average distance to members of another, nearest, cluster. The widths are defined as the

Usage

silinfo(cluster, dist)

Arguments

cluster

vector with assignments of data elements to clusters

dist

distance object or matrix

Details

The function signature is very similar to cluster::silhouette but the implementation has important differences. This implementation requires both the dist object and and cluster vector must have names. This prevents accidental assignment of silhouette widths to the wrong elements.

Value

list, analogous to object within output from cluster::pam. In particular, the list has a component widths. The widths object is matrix with one row per data item, with column sil_width holding the silhouette width.

Examples


# construct a manual clustering of the iris dataset
iris.data = iris[, 1:4]
rownames(iris.data) = paste0("iris_", seq_len(nrow(iris.data)))
iris.dist = dist(iris.data)
iris.clusters = setNames(as.integer(iris$Species), rownames(iris.data))

# compute sharpness values based on silhouette widths
silinfo(iris.clusters, iris.dist)


[Package ksharp version 0.1.0.1 Index]