R/clustering_functions.R
Optimal_Clusters_Medoids.Rd
Optimal number of Clusters for the partitioning around Medoids functions
Optimal_Clusters_Medoids(
data,
max_clusters,
distance_metric,
criterion = "dissimilarity",
clara_samples = 0,
clara_sample_size = 0,
minkowski_p = 1,
swap_phase = TRUE,
threads = 1,
verbose = FALSE,
plot_clusters = TRUE,
seed = 1
)
matrix or data.frame. If both clara_samples and clara_sample_size equal 0, then the data parameter can be also a dissimilarity matrix, where the main diagonal equals 0.0 and the number of rows equals the number of columns
either a numeric value, a contiguous or non-continguous numeric vector specifying the cluster search space
a string specifying the distance method. One of, euclidean, manhattan, chebyshev, canberra, braycurtis, pearson_correlation, simple_matching_coefficient, minkowski, hamming, jaccard_coefficient, Rao_coefficient, mahalanobis, cosine
one of 'dissimilarity' or 'silhouette'
number of samples to draw from the data set in case of clustering large applications (clara)
fraction of data to draw in each sample iteration in case of clustering large applications (clara). It should be a float number greater than 0.0 and less or equal to 1.0
a numeric value specifying the minkowski parameter in case that distance_metric = "minkowski"
either TRUE or FALSE. If TRUE then both phases ('build' and 'swap') will take place. The 'swap_phase' is considered more computationally intensive.
an integer specifying the number of cores to run in parallel. Openmp will be utilized to parallelize the number of sample draws
either TRUE or FALSE, indicating whether progress is printed during clustering
TRUE or FALSE, indicating whether the iterative results should be plotted. See the details section for more information
integer value for random number generator (RNG)
a list of length equal to the max_clusters parameter (the first sublist equals NULL, as dissimilarities and silhouette widths can be calculated if the number of clusters > 1). If plot_clusters is TRUE then the function plots also the results.
In case of plot_clusters = TRUE, the first plot will be either a plot of dissimilarities or both dissimilarities and silhouette widths giving an indication of the optimal number of the clusters. Then, the user will be asked to give an optimal value for the number of the clusters and after that the second plot will appear with either the dissimilarities or the silhouette widths belonging to each cluster.
In case that the max_clusters parameter is a contiguous or non-contiguous vector then plotting is disabled. Therefore, plotting is enabled only if the max_clusters parameter is of length 1.
if (FALSE) {
data(soybean)
dat = soybean[, -ncol(soybean)]
opt_md = Optimal_Clusters_Medoids(dat, 10, 'jaccard_coefficient', plot_clusters = FALSE)
#----------------------------
# non-contiguous search space
#----------------------------
search_space = c(2,5)
opt_md = Optimal_Clusters_Medoids(dat, search_space, 'jaccard_coefficient', plot_clusters = FALSE)
}