downsample_majority.Rd
Downsamples the majority class in binary classification setting to the size of minority class by randomly selecting majority class to match the number of minority class
downsample_majority(x, classVarName, arrangeVarName, seed = 100, shuffle = FALSE)
x | A dataframe |
---|---|
classVarName | Name of the binary class column |
arrangeVarName | Name of the variable to arrange by |
seed | Seed chosen for sampling, defaults to 100 |
shuffle | Whether to shuffle the dataframe at the end. This cannot be TRUE when arrangeVarName is specified. Shuffle used the seed value seed + 1. |
iris2 <- iris[c(1:25, 51:100), ] iris2$Species <- factor(iris2$Species) sampled <- downsample_majority(iris2, "Species") table(sampled$Species)#> #> setosa versicolor #> 25 25