medinfo: compute info on distances to medoids/centroids

Description Usage Arguments Value Examples

View source: R/medinfo.R

Description

Analogous in structure to silinfo and neiinfo, it computes a "widths" matrix assessing how well each data point belongs to its cluster. Here, this measure is the ratio of two distances: in the numerator, the distance from the point to the nearest cluster center, and in the denominator, from the point to its own cluster center.

Usage

1
medinfo(cluster, data, silwidths)

Arguments

cluster

named vector

data

matrix with raw data

silwidths

matrix with silhouette widths

Value

list with component widths. The widths object is a matrix with one row per data item, with column med_ratio holding the sharpness measure.

Examples

1
2
3
4
5
6
7
8
9
# 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 sharpnessvalues based on medoids
iris.silinfo = silinfo(iris.clusters, iris.dist)
medinfo(iris.clusters, iris.data, iris.silinfo$widths)

ksharp documentation built on Jan. 26, 2020, 5:06 p.m.