smotenc: SMOTENC Algorithm

View source: R/smotenc_impl.R

smotencR Documentation

SMOTENC Algorithm

Description

SMOTENC generates new examples of the minority class using nearest neighbors of these cases, and can handle categorical variables

Usage

smotenc(df, var, k = 5, over_ratio = 1)

Arguments

df

data.frame or tibble. Must have 1 factor variable and remaining numeric variables.

var

Character, name of variable containing factor variable.

k

An integer. Number of nearest neighbor that are used to generate the new examples of the minority class.

over_ratio

A numeric value for the ratio of the majority-to-minority frequencies. The default value (1) means that all other levels are sampled up to have the same frequency as the most occurring level. A value of 0.5 would mean that the minority levels will have (at most) (approximately) half as many rows than the majority level.

Details

The parameter neighbors controls the way the new examples are created. For each currently existing minority class example X new examples will be created (this is controlled by the parameter over_ratio as mentioned above). These examples will be generated by using the information from the neighbors nearest neighbor of each example of the minority class. The parameter neighbors controls how many of these neighbor are used. Columns can be numeric and categorical with no missing data.

Value

A data.frame or tibble, depending on type of df.

References

Chawla, N. V., Bowyer, K. W., Hall, L. O., and Kegelmeyer, W. P. (2002). Smote: Synthetic minority over-sampling technique. Journal of Artificial Intelligence Research, 16:321-357.

See Also

step_smotenc() for step function of this method

Other Direct Implementations: adasyn(), bsmote(), nearmiss(), smote(), tomek()

Examples

circle_numeric <- circle_example[, c("x", "y", "class")]

res <- smotenc(circle_numeric, var = "class")

res <- smotenc(circle_numeric, var = "class", k = 10)

res <- smotenc(circle_numeric, var = "class", over_ratio = 0.8)

themis documentation built on Aug. 15, 2023, 1:05 a.m.