mlr_task_generators_moons: Moons Cluster Task Generator

mlr_task_generators_moonsR Documentation

Moons Cluster Task Generator

Description

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

Id Type Default Range
sd numeric - [0, \infty)

Super class

mlr3::TaskGenerator -> TaskGeneratorMoons

Methods

Public methods

Inherited methods

TaskGeneratorMoons$new()

Creates a new instance of this R6 class.

Usage
TaskGeneratorMoons$new()

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.

See Also

  • Dictionary of TaskGenerators: mlr3::mlr_task_generators

  • 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

Examples

generator = tgen("moons")
plot(generator, n = 200)

task = generator$generate(200)
str(task$data())

mlr3cluster documentation built on Sept. 17, 2026, 5:09 p.m.