Skip to contents

This function generates samples from a uniform distribution to be used as noise variables. This can be used to assess the effect of high-dimensions on a model fit, and explainers.

Usage

add_noise_vars(data, n_vars = 2)

Arguments

data

A matrix or data frame with three columns (x, y, class).

n_vars

Integer; number of additional variables to generate.

Value

A data frame with three+n_vars columns, like:

x1

Random uniform coordinate

x2

Random uniform coordinate

x3

From the original data x

x4

From the original data y

class

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

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)

df <- add_noise_vars(df, 2)
head(df)
#>          x1        x2        x3        x4 class
#> 1 0.2416616 0.3025888 0.5675952 0.5485005 Below
#> 2 0.6165934 0.2354880 0.4260448 0.3920975 Below
#> 3 0.5003837 0.3543644 0.4958921 0.3064470 Below
#> 4 0.2797021 0.6955940 0.3227430 0.6808239 Above
#> 5 0.2051673 0.2593534 0.3820237 0.5811095 Above
#> 6 0.4335316 0.5574318 0.2340915 0.4497553 Above