dsg_source_regions: Benchmark source from a synthetic generator

View source: R/dsg_benchmark.R

dsg_source_regionsR Documentation

Benchmark source from a synthetic generator

Description

Builds a dsg_source() from a generator of feature vectors and a list of labelling rules (the real drift states). Virtual drift states are made by regional sub-sampling, as in Hinder et al. (2026): the feature space is split into the Voronoi cells of a k-means clustering, the cells are dealt into n_variants groups, and each virtual state keeps only the samples falling in its group.

Usage

dsg_source_regions(
  generator,
  labelers,
  n_clusters = 20,
  n_variants = 2,
  init_size = 1000,
  ...
)

Arguments

generator

Function generator(n) returning a data frame with n feature vectors.

labelers

List of labelling functions, see dsg_source().

n_clusters

Approximate number of k-means clusters; rounded up to the next multiple of n_variants above n_clusters, as in the reference code.

n_variants

Number of virtual drift states.

init_size

Number of samples used to fit the clustering.

...

Further arguments for dsg_source().

Value

dsg_source object

Examples

set.seed(1)
source <- dsg_source_regions(
  generator = function(n) data.frame(a = stats::runif(n), b = stats::runif(n)),
  labelers = list(function(x) as.integer(x$a > x$b), function(x) as.integer(x$a > 0.5)),
  test_size = 200, n_perm = 200
)
source

heimdall documentation built on Dec. 2, 2026, 5:08 p.m.