Metric will be computed from 2 to max_k clusters. Note that the row number in results will be different from k.

compute_metric(dmat, clusters, metric_name, max_k = 14)

Arguments

dmat

distance matrix output of compute_dmat() or stats::dist()

clusters

output of compute_clusters() or fastcluster::hclust()

metric_name

"silhouette" or "dunn"

max_k

maximum number of clusters to cut using dendextend::cutree(). Default is 14.

Value

a data frame with columns k and score

Examples

data_to_cluster <- iris[c("Petal.Length", "Sepal.Length")]
dmat <- compute_dmat(data_to_cluster, "euclidean", TRUE)
clusters <- compute_clusters(dmat, "complete")
compute_metric(dmat, clusters, "dunn")
#>     k      score
#> 1   2 0.04360231
#> 2   3 0.05621762
#> 3   4 0.07360085
#> 4   5 0.07065255
#> 5   6 0.10059379
#> 6   7 0.10977727
#> 7   8 0.11995125
#> 8   9 0.12115467
#> 9  10 0.12442737
#> 10 11 0.13670682
#> 11 12 0.13670682
#> 12 13 0.15281355
#> 13 14 0.15995945