dataBalancing: Perform data balancing

View source: R/SOptim_DataBalancing.R

dataBalancingR Documentation

Perform data balancing

Description

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

Usage

dataBalancing(x, method)

Arguments

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.

Value

A data frame with balanced classes.

Examples


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")


joaofgoncalves/SegOptim documentation built on Feb. 5, 2024, 11:10 p.m.