This function is meant to be used with compute_metric. For Gap statistic,
use cluster::maxSE()
.
optimal_score(x, method = c("firstmax", "globalmax", "firstmin", "globalmin"))
a numeric vector
one of "firstmax", "globalmax", "firstmin" or "globalmin"
the index (not k) of the identified maximum or minimum score
data_to_cluster <- iris[c("Petal.Length", "Sepal.Length")]
dmat <- compute_dmat(data_to_cluster, "euclidean", TRUE)
clusters <- compute_clusters(dmat, "complete")
res <- compute_metric(dmat, clusters, "dunn")
optimal_score(res$score, method = "firstmax")
#> [1] 3