balance_class: Balances Classes in Dataset

View source: R/balance_data.R

balance_classR Documentation

Balances Classes in Dataset

Description

Balances classes in dataset by undersampling or oversampling.

Usage

balance_class(
  data,
  class,
  response,
  method = "under",
  prop = 0.5,
  seed = 628,
  thresh = 20,
  quiet = FALSE
)

Arguments

data

dataset to be balanced.

class

categorical variable in dataset to be balanced by. This is an optional argument.

response

response variable in dataset.

method

specifies whether undersampling or oversample should be performed. Takes the value "under" or "over".

prop

desired distribution of response per each class.

seed

an integer for set.seed

quiet

a logical specifying whether output should be printed to the console.

Details

This function balances the classes of a dataset via undersampling or oversampling using the ROSE package. The class argument is optional. If it is not entered, then the entire dataset will be balanced as a whole. ## Not run: if(interactive()){ # NEED TO CHANGE data(property_prices) balance_class(data = property_prices, response = sale_price, class = crime_rate) } ## End(Not run)

Value

balanced data.table.


Nanoputian628/nano documentation built on Oct. 30, 2023, 3:28 p.m.