Learn R Programming

daltoolbox (version 1.3.727)

bal_oversampling: Random or SMOTE-based class oversampling

Description

Balance class distributions by randomly replicating minority examples or by generating synthetic samples with a local SMOTE implementation.

Usage

bal_oversampling(attribute, method = c("smote", "random"), k = 5, seed = NULL)

Value

returns an object of class bal_oversampling

Arguments

attribute

target class attribute name

method

oversampling strategy: "smote" or "random"

k

number of nearest neighbors used by the SMOTE strategy

seed

optional random seed for reproducibility

References

Chawla, N. V., Bowyer, K. W., Hall, L. O., & Kegelmeyer, W. P. (2002). SMOTE: Synthetic Minority Over-sampling Technique.

Examples

Run this code
data(iris)
iris_imb <- iris[c(1:50, 51:71, 101:111), ]
bal <- bal_oversampling("Species", method = "smote", seed = 123)
iris_bal <- transform(bal, iris_imb)
table(iris_bal$Species)

Run the code above in your browser using DataLab