Skip to contents

Generates a synthetic two-dimensional dataset using random uniform values. Each point is assigned a class label based on whether it lies above all coordinate thresholds provided. Coordinates can be supplied directly as a matrix/data frame or indirectly via a JSON file containing an array of coordinate pairs.

Usage

create_data(
  coord_filepath = NULL,
  coord = NULL,
  n_samples = 10000,
  type = "uniform",
  seed = 1835,
  gap = 0,
  r = 0
)

Arguments

coord_filepath

A character string specifying a file path to a JSON file containing a list/array of coordinate pairs. Optional if coord is supplied.

coord

A matrix or data frame with two columns (x and y) specifying threshold coordinates. Optional if coord_filepath is supplied.

n_samples

Integer; number of synthetic 2D points to generate.

type

String; How should the points be generated. Can be either 'uniform' (default), 'normal', or 'grid'

seed

Integer; Random seed to be used for generating dataset.

gap

Numeric; Value close to 0 defining gap at the boundary, less than 0.2

r

Numeric; Correlation for generating normal sample, between (-0.9, 0.9), default 0.

Value

A data frame with three columns:

x

Random uniform x-coordinate

y

Random uniform y-coordinate

class

Binary class label ("Above" or "Below")

Details

A point is labelled class = 1 if it is above all coordinate thresholds such that: $$x > coord[,1] \; \text{and} \; y > coord[,2]$$

Otherwise, the point is labelled 0.

Examples


coords <- matrix(c(0.2, 0.3,
                   0.4, 0.5,
                   0.6, 0.7), ncol = 2, byrow = TRUE)

df <- create_data(coord = coords, n_samples = 500, seed = 717)
head(df)
#>           x         y class
#> 1 0.5675952 0.5485005 Below
#> 2 0.4260448 0.3920975 Below
#> 3 0.4958921 0.3064470 Below
#> 4 0.3227430 0.6808239 Above
#> 5 0.3820237 0.5811095 Above
#> 6 0.2340915 0.4497553 Above