Computes the average silhouette width for a clustering solution using Euclidean distance.
Note
This process can be very slow for large matrices if single-threaded. Use multiple threads to take advantage of parallel computation for significantly faster results.
Examples
# Preparing the inputs
set.seed(42)
pc_matrix <- matrix(data = rnorm(n = 10000 * 15, sd = 2), nrow = 10000, ncol = 15)
cluster_numbers <- as.integer(runif(n = 10000, min = 1, max = 10))
# Getting the mean silhouette score
n_threads <- parallel::detectCores()
score <- get_silhouette_mean(pc_matrix, cluster_numbers, n_threads)
#> [silhouette_avg] Starting computation...
#> [silhouette_avg] Using 16 threads...
print(score)
#> [1] -0.006122089
