View source: R/metric-silhouette.R
silhouette | R Documentation |
Measures silhouette between clusters
silhouette(object, new_data = NULL, dists = NULL, dist_fun = Rfast::Dist)
object |
A fitted tidyclust model |
new_data |
A dataset to predict on. If |
dists |
A distance matrix. Used if |
dist_fun |
A function for calculating distances between observations. Defaults to Euclidean distance on processed data. |
silhouette_avg()
is the corresponding cluster metric function that
returns the average of the values given by silhouette()
.
A tibble giving the silhouette for each observation.
kmeans_spec <- k_means(num_clusters = 5) %>%
set_engine("stats")
kmeans_fit <- fit(kmeans_spec, ~., mtcars)
dists <- mtcars %>%
as.matrix() %>%
dist()
silhouette(kmeans_fit, dists = dists)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.