powered by
Measures silhouette between clusters
silhouette( object, new_data = NULL, dists = NULL, dist_fun = philentropy::distance )
A tibble giving the silhouette for each observation.
A fitted tidyclust model
A dataset to predict on. If NULL, uses trained clustering.
NULL
A distance matrix. Used if new_data is NULL.
new_data
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().
silhouette_avg()
silhouette()
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)
Run the code above in your browser using DataLab