Skip to contents

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():

mlr_task_generators$get("moons")
tgen("moons")

Parameters

IdTypeDefaultRange
sdnumeric-\([0, \infty)\)

See also

Other TaskGenerator: mlr_task_generators_blobs

Super class

mlr3::TaskGenerator -> TaskGeneratorMoons

Methods

Inherited methods


TaskGeneratorMoons$new()

Creates a new instance of this R6 class.

Usage


TaskGeneratorMoons$plot()

Creates a simple plot of generated data, colored by cluster membership.

Usage

TaskGeneratorMoons$plot(n = 200L, pch = 19L, ...)

Arguments

n

(integer(1))
Number of samples to draw for the plot. Default is 200.

pch

(integer(1))
Point char. Passed to graphics::plot().

...

(any)
Additional arguments passed to graphics::plot().


TaskGeneratorMoons$clone()

The objects of this class are cloneable with this method.

Usage

TaskGeneratorMoons$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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>