compare_caps {fdacluster} | R Documentation |
Generates results of multiple clustering strategies
Description
This function searches for clusters in the input data set using different
strategies and generates an object of class mcaps
which stores multiple
objects of class caps
. This is a helper function to facilitate comparison
of clustering methods and choice of an optimal one.
Usage
compare_caps(
x,
y,
n_clusters = 1:5,
metric = c("l2", "pearson"),
clustering_method = c("kmeans", "hclust-complete", "hclust-average", "hclust-single",
"dbscan"),
warping_class = c("affine", "dilation", "none", "shift", "srsf"),
centroid_type = c("mean", "medoid", "median", "lowess", "poly"),
cluster_on_phase = FALSE
)
Arguments
x |
A numeric vector of length |
y |
Either a numeric matrix of shape |
n_clusters |
An integer vector specifying a set of clustering partitions
to create. Defaults to |
metric |
A string specifying the metric used to compare curves. Choices
are |
clustering_method |
A character vector specifying one or more clustering
methods to be fit. Choices are |
warping_class |
A character vector specifying one or more classes of
warping functions to use for curve alignment. Choices are |
centroid_type |
A character vector specifying one or more ways to
compute centroids. Choices are |
cluster_on_phase |
A boolean specifying whether clustering should be
based on phase variation or amplitude variation. Defaults to |
Value
An object of class mcaps
which is a tibble::tibble
storing the
objects of class caps
in correspondence of each combination of possible
choices from the input arguments.
Examples
#----------------------------------
# Compare k-means results with k = 1, 2, 3, 4, 5 using mean centroid and
# various warping classes.
## Not run:
sim30_mcaps <- compare_caps(
x = simulated30_sub$x,
y = simulated30_sub$y,
warping_class = c("none", "shift", "dilation", "affine"),
clustering_method = "kmeans",
centroid_type = "mean"
)
## End(Not run)
#----------------------------------
# Then visualize the results
# Either with ggplot2 via ggplot2::autoplot(sim30_mcaps)
# or using graphics::plot()
# You can visualize the WSS values:
plot(sim30_mcaps, validation_criterion = "wss", what = "mean")
plot(sim30_mcaps, validation_criterion = "wss", what = "distribution")
# Or the average silhouette values:
plot(sim30_mcaps, validation_criterion = "silhouette", what = "mean")
plot(sim30_mcaps, validation_criterion = "silhouette", what = "distribution")