RUS | R Documentation |
A balanced dataset would be return by using random under-sampling (RUS) algorithm.
RUS(data, outcome, perc_min = 100)
data |
A dataset containing the predictors and the outcome. The predictors
can be continuous ( |
outcome |
The column number or the name of the outcome variable in the dataset. |
perc_min |
The desired percentage of the size of minority samples that the majority samples would be reached in the new dataset. The default is 100. |
The random under-sampling algorithm randomly chooses the majority samples without replacement according to the sample size of minority class, in order to get a more balanced dataset.
A new dataset has been balanced.
data(abalone)
table(abalone$Class)
newdata1 <- RUS(abalone, 'Class')
table(newdata1$Class)
newdata2 <- RUS(abalone, 'Class', perc_min=200)
table(newdata2$Class)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.