upsample_minority.Rd
Upsamples the minority class in binary classification setting to the size of majority class by randomly selecting minority class with repition to match the number of majority class
upsample_minority(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 <- upsample_minority(iris2, "Species") table(sampled$Species)#> #> setosa versicolor #> 50 50