This function undersamples the majority class in a data frame to match the size of the minority class.
undersample_majority(x, vname)
Arguments
- x
data frame containing the data to be undersampled
- vname
character string specifying the name of the column containing the class labels
Value
data frame with the majority class undersampled to match the size of the minority class
Examples
data <- data.frame(class = c(rep("A", 10), rep("B", 100)),
feature1 = rnorm(110),
feature2 = rnorm(110))
undersampled_data <- undersample_majority(data, "class")