Clustering is a central task in big data analyses and clusters are often Gaussian or near Gaussian. However, a flexible Gaussian cluster simulation tool with precise control over the size, variance, and spacing of the clusters in NXN dimensional space does not exist. This is why we created clusterlab. The algorithm first creates X points equally spaced on the circumference of a circle in 2D space. These form the centers of each cluster to be simulated. Additional samples are added by adding Gaussian noise to each cluster center and concatenating the new sample co-ordinates. Then if the feature space is greater than 2D, the generated points are considered principal component scores and projected into N dimensional space using linear combinations using fixed eigenvectors. Clusterlab is highly customizable and well suited to testing class discovery tools across a range of fields.
Here we simulate a 100 sample cluster with the default number of features (500). The standard deviation is left to default which is 1.
library(clusterlab)
synthetic <- clusterlab(centers=1,numbervec=100)
#> running clusterlab...
#> user has not set standard deviation of clusters, setting automatically...
#> finished.
Next, we simulate a 4 cluster dataset with a radius of 8 for the circle on which the centers are placed. Then the standard deviations of the cluster are the same, 2.5. We set the alphas to 1, which is the value the clusters are pushed apart from one another. So there are two ways to seperate the clusters, either by the radius of the circle, or by the alpha parameter.
library(clusterlab)
synthetic <- clusterlab(centers=4,r=8,sdvec=c(2.5,2.5,2.5,2.5),
alphas=c(1,1,1,1),centralcluster=FALSE,
numbervec=c(50,50,50,50))
#> running clusterlab...
#> finished.
The same as above, but 2 clusters have different variances to the other 2.
library(clusterlab)
synthetic <- clusterlab(centers=4,r=8,sdvec=c(1,1,2.5,2.5),
alphas=c(1,1,1,1),centralcluster=FALSE,
numbervec=c(50,50,50,50))
#> running clusterlab...
#> finished.
The alpha parameter allows any number of clusters to be pushed away from the others. Here 1 cluster is pushed away slightly.
library(clusterlab)
synthetic <- clusterlab(centers=4,r=8,sdvec=c(2.5,2.5,2.5,2.5),
alphas=c(1,2,1,1),centralcluster=FALSE,
numbervec=c(50,50,50,50))
#> running clusterlab...
#> finished.
Here we change the number vec entry for 1 cluster to a smaller value, therefore lowering the number of samples in the specified cluster.
library(clusterlab)
synthetic <- clusterlab(centers=4,r=8,sdvec=c(2.5,2.5,2.5,2.5),
alphas=c(1,1,1,1),centralcluster=FALSE,
numbervec=c(15,50,50,50))
#> running clusterlab...
#> finished.
In this case we change the centralcluster parameter to TRUE, in order to make a central cluster as well as those placed on the circumference.
library(clusterlab)
synthetic <- clusterlab(centers=5,r=8,sdvec=c(2.5,2.5,2.5,2.5,2.5),
alphas=c(2,2,2,2,2),centralcluster=TRUE,
numbervec=c(50,50,50,50,50))
#> running clusterlab...
#> finished.
Clusterlab also keeps track of the cluster allocations and gives each sample an unique ID. This may prove useful when scoring class discovery algorithms assignments.
head(synthetic$identity_matrix)
#> sampleID cluster
#> 1 c1s1 1
#> 2 c1s2 1
#> 3 c1s3 1
#> 4 c1s4 1
#> 5 c1s5 1
#> 6 c1s6 1