balance_class | R Documentation |
Balances classes in dataset by undersampling or oversampling.
balance_class(
data,
class,
response,
method = "under",
prop = 0.5,
seed = 628,
thresh = 20,
quiet = FALSE
)
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. |
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)
balanced data.table.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.