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():
Parameters
| Id | Type | Default | Range |
| k | integer | - | \([1, \infty)\) |
| d | integer | - | \([1, \infty)\) |
| sd | numeric | - | \([0, \infty)\) |
| center_box | numeric | - | \([0, \infty)\) |
See also
as.data.table(mlr_task_generators)for a table of available TaskGenerators in the running session (depending on the loaded packages).
Super class
mlr3::TaskGenerator -> TaskGeneratorBlobs
Methods
TaskGeneratorBlobs$plot()
Creates a simple plot of the first two features of generated data, colored by cluster membership.
Arguments
n(
integer(1))
Number of samples to draw for the plot. Default is 200.pch(
integer(1))
Point char. Passed tographics::plot()....(any)
Additional arguments passed tographics::plot().
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
