Skip to contents

This function removes points outside of a elliptical region

Usage

trim_shape(data, r = 0.6)

Arguments

data

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

r

Numeric; Correlation defining the shape, between -0.9 and 0.9; default 0.6

Value

The rows of data that fall inside the elliptical region, with the same columns:

x

x-coordinate

y

y-coordinate

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 <- trim_shape(df)
plot(df$x, df$y, col=ifelse(df$class == "Above", "red", "yellow"))