| p_cluster | R Documentation |
Computes a silhouette coefficient for each non-noise point using the
precomputed (or internally derived) DC-distance matrix rather than raw
Euclidean distances. This matches the formula used by
sklearn.metrics.silhouette_samples with metric="precomputed"
(Python reference: disco.py, line 280):
s(i) = \frac{b(i) - a(i)}{\max(a(i),\, b(i))}
where a(i) is the mean DC distance from i to all other points
in the same cluster and b(i) is the minimum over other clusters of
the mean DC distance from i to that cluster. Points that form a
singleton cluster score 0, as defined in the DISCO paper (and as in
silhouette_samples); version 0.1.1 incorrectly gave them 1.
p_cluster(X, labels, min_points = 5, precomputed_dc_dists = FALSE)
X |
Either (a) a numeric matrix of raw data ( |
labels |
An integer vector of cluster labels of length |
min_points |
Positive integer; used only when
|
precomputed_dc_dists |
Logical. If |
A numeric vector of length n with per-point silhouette-style
scores in [-1, 1].
disco_samples, compute_dc_distances
set.seed(7)
X <- matrix(rnorm(60), ncol = 2)
labels <- rep(c(0L, 1L, 2L), each = 10)
p_cluster(X, labels)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.