View source: R/cluster_choice.R
| cluster_choice | R Documentation |
One-call sweep across any combination of k, dissimilarity metric, and
clustering algorithm for distance-based sequence clustering. Mirrors
compare_mmm for model-based clustering: returns a data
frame with one row per swept configuration, a best marker on
the silhouette-max row in the print method, and a plot() that
adapts to the swept axes.
cluster_choice(
data,
k = 2:5,
dissimilarity = "hamming",
method = "ward.D2",
...
)
data |
Sequence data (data frame or matrix) – forwarded to
|
k |
Integer vector of cluster counts to sweep. Default
|
dissimilarity |
Character vector of dissimilarity metrics. Use
|
method |
Character vector of clustering algorithms. Use
|
... |
Other arguments forwarded to
|
A cluster_choice object (a data.frame subclass) with
one row per (k, dissimilarity, method) combination and columns:
The configuration for that row.
Overall average silhouette width (from
cluster::silhouette, computed inside
build_clusters).
Size-weighted mean of within-cluster distances, in the units of the row's dissimilarity.
Cluster-size balance bounds
and their ratio (max / min).
build_clusters, compare_mmm for
the model-based equivalent, cluster_diagnostics for
the post-fit diagnostic surface on a single clustering.
seqs <- data.frame(V1 = sample(c("A","B","C"), 40, TRUE),
V2 = sample(c("A","B","C"), 40, TRUE))
cluster_choice(seqs, k = 2:4)
# Sweep dissimilarities at fixed k
cluster_choice(seqs, k = 3, dissimilarity = c("hamming", "lcs", "jaccard"))
# Full grid of k x dissimilarity
cluster_choice(seqs, k = 2:4, dissimilarity = c("hamming", "lcs"))
# "all" sentinel
cluster_choice(seqs, k = 3, dissimilarity = "all")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.