View source: R/clustering_core.R
| run_clustering | R Documentation |
This function performs clustering on a numeric matrix using one of six common clustering methods: KMeans, Hierarchical, DBSCAN, PAM, Gaussian Mixture Model (GMM), or Spectral Clustering.
run_clustering(data, method, k = 3, eps = 0.5, minPts = 5)
data |
A numeric matrix or data frame, typically standardized, to be clustered. |
method |
A string indicating the clustering method to use. Options are: "KMeans", "Hierarchical", "DBSCAN", "PAM", "GMM", "Spectral". |
k |
An integer specifying the number of clusters. Required for KMeans, Hierarchical, PAM, GMM, and Spectral. |
eps |
A numeric value specifying the epsilon parameter for DBSCAN. Default is 0.5. |
minPts |
An integer specifying the minimum number of points for DBSCAN. Default is 5. |
A list containing two elements:
A vector of cluster labels assigned to each observation.
An object of class silhouette representing silhouette widths.
data(iris)
result <- run_clustering(scale(iris[, 1:4]), method = "KMeans", k = 3)
print(result$cluster)
if (interactive()) {
plot(result$silhouette)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.