View source: R/trans_sample_oversampling.R
| bal_oversampling | R Documentation |
Balance class distributions by generating synthetic minority examples with the SMOTE family (classic SMOTE, Borderline-SMOTE, ADASYN) or by random replication.
bal_oversampling(
attribute,
method = c("smote", "borderline", "adasyn", "random"),
k = 5,
m = 10,
seed = NULL
)
attribute |
target class attribute name |
method |
oversampling strategy: |
k |
number of nearest neighbors used to interpolate synthetic samples |
m |
number of neighbors used to assess the danger/difficulty of a minority instance (borderline/adasyn) |
seed |
optional seed for reproducibility |
All synthetic variants interpolate a base minority instance toward one of its
k nearest minority neighbors; nominal features are set by majority vote among those
neighbors (SMOTE-NC) instead of a coin flip. "borderline" synthesizes only from
danger instances (those whose m nearest neighbors are mostly of other classes),
concentrating new points near the decision boundary; "adasyn" allocates more synthetic
samples to harder-to-learn minority instances.
returns an object of class bal_oversampling
Chawla, N. V., Bowyer, K. W., Hall, L. O., & Kegelmeyer, W. P. (2002). SMOTE: Synthetic Minority Over-sampling Technique. Journal of Artificial Intelligence Research, 16:321-357. Han, H., Wang, W.-Y., & Mao, B.-H. (2005). Borderline-SMOTE: A New Over-Sampling Method in Imbalanced Data Sets Learning. In ICIC 2005, 878-887. He, H., Bai, Y., Garcia, E. A., & Li, S. (2008). ADASYN: Adaptive Synthetic Sampling Approach for Imbalanced Learning. In IJCNN 2008, 1322-1328.
data(iris)
iris_imb <- iris[c(1:50, 51:71, 101:111), ]
bal <- bal_oversampling("Species", method = "smote")
iris_bal <- transform(bal, iris_imb)
table(iris_bal$Species)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.