A TaskGenerator for two interleaving half circles ("moons"), in the spirit of
sklearn.datasets.make_moons().
The n observations are split evenly between an upper half circle centered at the origin and a lower half circle
shifted to the right and down so that the two arcs interleave.
Each observation is perturbed with Gaussian noise of standard deviation sd.
The generated TaskClust only contains the numeric features x1 and x2; the cluster membership is not
stored in the task.
The parameter sd is initialized to 0.1.
The clusters are not convex, which makes this generator a standard test case for density-based and connectivity-based methods such as DBSCAN, single linkage or spectral clustering, where centroid-based methods such as k-means fail.
Dictionary
This TaskGenerator can be instantiated via the dictionary mlr_task_generators or with the associated sugar function tgen():
See also
as.data.table(mlr_task_generators)for a table of available TaskGenerators in the running session (depending on the loaded packages).
Other TaskGenerator:
mlr_task_generators_blobs
Super class
mlr3::TaskGenerator -> TaskGeneratorMoons
Methods
TaskGeneratorMoons$plot()
Creates a simple plot of generated data, colored by cluster membership.
Arguments
n(
integer(1))
Number of samples to draw for the plot. Default is200.pch(
integer(1))
Point char. Passed tographics::plot()....(any)
Additional arguments passed tographics::plot().
Examples
generator = tgen("moons")
plot(generator, n = 200)
task = generator$generate(200)
str(task$data())
#> Classes ‘data.table’ and 'data.frame': 200 obs. of 2 variables:
#> $ x1: num 0.587 1.677 -0.422 1.701 -0.422 ...
#> $ x2: num 0.748 -0.445 0.84 -0.156 0.936 ...
#> - attr(*, ".internal.selfref")=<pointer: 0x55bfc7061a30>