upsample_minority: Upsample minority class to the size of majority class

Description Usage Arguments Examples

Description

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

Usage

1
2
upsample_minority(x, classVarName, arrangeVarName, seed = 100,
  shuffle = FALSE)

Arguments

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.

Examples

1
2
3
4
iris2         <- iris[c(1:25, 51:100), ]
iris2$Species <- factor(iris2$Species)
sampled <- upsample_minority(iris2, "Species")
table(sampled$Species)

talegari/sidekicks documentation built on May 30, 2019, 8:40 a.m.