Skip to contents

A TaskGenerator for isotropic Gaussian blobs, in the spirit of sklearn.datasets.make_blobs(). k cluster centers are drawn uniformly from the hypercube [-center_box, center_box]^d, and the n observations are assigned to the centers in a balanced fashion and perturbed with Gaussian noise of standard deviation sd in each of the d dimensions. The generated TaskClust only contains the numeric features x1, ..., xd; the cluster membership is not stored in the task. The parameters are initialized to k = 3, d = 2, sd = 1, and center_box = 10.

Dictionary

This TaskGenerator can be instantiated via the dictionary mlr_task_generators or with the associated sugar function tgen():

mlr_task_generators$get("blobs")
tgen("blobs")

Parameters

IdTypeDefaultRange
kinteger-\([1, \infty)\)
dinteger-\([1, \infty)\)
sdnumeric-\([0, \infty)\)
center_boxnumeric-\([0, \infty)\)

See also

Super class

mlr3::TaskGenerator -> TaskGeneratorBlobs

Methods

Inherited methods


TaskGeneratorBlobs$new()

Creates a new instance of this R6 class.

Usage


TaskGeneratorBlobs$plot()

Creates a simple plot of the first two features of generated data, colored by cluster membership.

Usage

TaskGeneratorBlobs$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().


TaskGeneratorBlobs$clone()

The objects of this class are cloneable with this method.

Usage

TaskGeneratorBlobs$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

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


task = generator$generate(200)
str(task$data())
#> Classes ‘data.table’ and 'data.frame':	200 obs. of  2 variables:
#>  $ x1: num  -1.9 -11.38 -1.78 -3.96 -10.63 ...
#>  $ x2: num  2.824 1.495 -8.203 0.767 0.372 ...
#>  - attr(*, ".internal.selfref")=<pointer: 0x55d87331da30> 

# 4 well separated clusters in 3 dimensions
generator = tgen("blobs", k = 4, d = 3, sd = 0.5)
task = generator$generate(500)
task
#> 
#> ── <TaskClust> (500x3) ─────────────────────────────────────────────────────────
#> • Target:
#> • Properties: -
#> • Features (3):
#>   • dbl (3): x1, x2, x3