View source: R/SOptim_DataBalancing.R
dataBalancing | R Documentation |
An internal wrapper function for performing data balancing for single-class problems.
Two methods are available via the unbalanced
package: i) over-sampling
ubOver
or, ii) under-sampling ubUnder
dataBalancing(x, method)
x |
A data frame or matrix for balancing (by default the two first columns are assumed to be the segment ID and the train labels).The response variable of the unbalanced dataset (i.e., the column named as "train") must be a binary factor where the majority class is coded as 0's and the minority (the class of interest) as 1's. |
method |
A string defining the method to apply. Either "ubOver" for over-sampling the minority class or "ubUnder" for under-sampling the majority class. |
A data frame with balanced classes.
DF <- data.frame(SID=1:100,train=c(rep(0,90),rep(1,10)),matrix(rnorm(1000),10,100))
DF.over<-dataBalancing(x=DF, method="ubOver")
DF.under<-dataBalancing(x=DF,method="ubUnder")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.