downSample: Down- and Up-Sampling Imbalanced Data

Description Usage Arguments Details Value Author(s) Examples

Description

downSample will randomly sample a data set so that all classes have the same frequency as the minority class. upSample samples with replacement to make the class distributions equal

Usage

1
2
3
downSample(x, y, list = FALSE, yname = "Class")

upSample(x, y, list = FALSE, yname = "Class")

Arguments

x

a matrix or data frame of predictor variables

y

a factor variable with the class memberships

list

should the function return list(x, y) or bind x and y together? If TRUE, the output will be coerced to a data frame.

yname

if list = FALSE, a label for the class column

Details

Simple random sampling is used to down-sample for the majority class(es). Note that the minority class data are left intact and that the samples will be re-ordered in the down-sampled version.

For up-sampling, all of the original data are left intact and additional samples are added to the minority classes with replacement.

Value

Either a data frame or a list with elements x and y.

Author(s)

Max Kuhn

Examples

1
2
3
4
5
6

caret documentation built on May 2, 2019, 5:47 p.m.

Related to downSample in caret...