View source: R/parApplyDataBasedCA.R
| parApplyDataBasedCA | R Documentation |
Repeatedly applies a data-based clustering method to one dataset or a collection of datasets. Trials may be executed serially or in parallel.
parApplyDataBasedCA(
Data,
FUN,
NumberOfTrials = 1:100,
ClusterNo = NULL,
WorkersOrNo,
SocketType = "PSOCK",
SetSeed = TRUE,
...
)
Data |
Dataset accepted by |
FUN |
Function or character string naming a data-based clustering method. The
result should normally be a list containing a unique element named
|
NumberOfTrials |
Positive integer count or vector of positive integer trial identifiers.
A scalar |
ClusterNo |
Number of clusters passed to |
WorkersOrNo |
Missing, |
SocketType |
Character scalar passed to |
SetSeed |
Logical scalar. If |
... |
Further arguments passed to |
The dataset is passed to a formal argument named Data when available.
Otherwise, DataOrDistances or the first inspectable non-dots argument
is used.
For multiple datasets, errors raised while processing an individual dataset
are converted to warnings. The corresponding list element is returned as
NULL, while processing continues for the remaining datasets.
An internally created worker cluster is stopped automatically. A cluster
supplied through WorkersOrNo is not stopped.
For one dataset, a list with:
Cls_Matrix |
Matrix of clustering vectors, one column per trial, or |
ComputationTime |
Named numeric vector of elapsed trial times. |
Seeds |
Named integer vector of seeds, or |
CAobjects |
Named list containing the complete clustering result from every trial. |
For a collection of datasets, returns a list with one result per dataset.
Failed datasets are represented by NULL.
The default "PSOCK" cluster type is portable across the operating
systems supported by R. Objects required by FUN must be available or
serializable on each worker.
Set WorkersOrNo = NULL for deterministic serial testing.
Michael Thrun
Thrun, M. C.: Distance-Based Clustering Challenges for Unbiased Benchmarking Studies, Nature Scientific Reports, Vol. 11, pp. 18988, DOI: 10.1038/s41598-021-98126-1, 2021.
parApplyClusterAnalysis,
parApplyDistanceBasedCA,
makeCluster
simple_clustering <- function(Data, ClusterNo = 2) {
fit <- stats::kmeans(Data, centers = ClusterNo)
list(Cls = fit$cluster, Object = fit)
}
set.seed(2)
Data <- matrix(rnorm(80), ncol = 2)
result <- parApplyDataBasedCA(
Data = Data,
FUN = simple_clustering,
NumberOfTrials = 2,
ClusterNo = 2,
WorkersOrNo = NULL
)
result$Cls_Matrix
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.