This function samples the rows of a data.frame with balanced classes. Useful when original training set has severely unbalanced classes.

BalancedSample(df, sample_size = 5000, class_col = class_col)

Arguments

df

An object of class data.frame.

sample_size

Numeric. Size of the sample from each class.

class_col

A character vector with the name of the column that identify the classes.

Value

Returns a data.frame with n=sample_size rows per class randomly sampled.