spectral_clustering <- function(X,
n_clusters = 8,
n_components = NULL,
affinity = "rbf",
assign_labels = "kmeans",
n_init = 10) {
affinity_matrix <- affinity_kernel(X, kernel = affinity)
n_components <- if (is.null(n_components)) n_clusters else n_components
maps <-
spectral_embedding(affinity_matrix, n_components = n_components)
labels <-
assignment(maps, assign_labels, centers = n_clusters, nstart = n_init)
return(labels)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.