balanceMulticlassData: Balance multi-class data

View source: R/SOptim_DataBalancing.R

balanceMulticlassDataR Documentation

Balance multi-class data

Description

A simple function to perform data balancing for multi-class datasets and classification problems. It does over-sampling (or sampling with replacement) if the frequency value of the target class is below n and down-sampling (or sampling without replacement) if the frequency is above n.

Usage

balanceMulticlassData(x, class, n)

Arguments

x

A data frame to balance.

class

The name or the position of the column identifying the class (the column must be a factor variable).

n

Number of rows/observations to extract from each class? (integer)

Value

A data.frame with n rows by class.

Note

This function is just a rough fix for handling unbalanced datasets, use with care!...


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