A thin wrapper around ROSE::ROSE() that generates a synthetic balanced
sample by enlarging the feature space of minority and majority class
examples.
rose(
df,
var,
over_ratio = 1,
minority_prop = 0.5,
minority_smoothness = 1,
majority_smoothness = 1
)A data.frame or tibble, depending on type of df.
A data.frame or tibble. Must have 1 factor variable with exactly 2 levels and remaining numeric variables.
Character, name of variable containing the 2-level factor variable.
A numeric value for the total size of the synthetic data relative to twice the size of the majority class. Unlike the other over-sampling steps this is not a per-class target, so a named vector of ratios is not accepted here.
A numeric value between 0 and 1 for the proportion of
synthetic observations from the minority class. Defaults to 0.5, which
generates an equal split of minority and majority synthetic observations.
This parameter controls the class balance within the synthetic data,
while over_ratio controls the total size of the synthetic data.
A numeric. Shrink factor to be multiplied by the smoothing parameters to estimate the conditional kernel density of the minority class. Defaults to 1.
A numeric. Shrink factor to be multiplied by the smoothing parameters to estimate the conditional kernel density of the majority class. Defaults to 1.
The factor variable used to balance around must only have 2 levels.
The ROSE algorithm works by selecting an observation belonging to class k
and generating new examples in its neighborhood, which is determined by a
smoothing matrix H_k. Smaller values of minority_smoothness and
majority_smoothness shrink the entries of H_k, producing tighter
neighborhoods. This is a cautious choice when there is a concern that
excessively large neighborhoods could blur the boundaries between classes.
This function is a thin wrapper around ROSE::ROSE(). For full details on
the underlying implementation, see that function's documentation.
Lunardon, N., Menardi, G., and Torelli, N. (2014). ROSE: a Package for Binary Imbalanced Learning. R Journal, 6:79–89.
Menardi, G. and Torelli, N. (2014). Training and assessing classification rules with imbalanced data. Data Mining and Knowledge Discovery, 28:92–122.
step_rose() for step function of this method
Other Direct Implementations:
adasyn(),
bsmote(),
cluster_centroids(),
cnn(),
enn(),
instance_hardness(),
kmeans_smote(),
ncl(),
nearmiss(),
oss(),
smogn(),
smote(),
smoten(),
smotenc(),
svmsmote(),
tomek()
rose(circle_example[, c("x", "y", "class")], var = "class")
rose(circle_example[, c("x", "y", "class")], var = "class", over_ratio = 0.8)
Run the code above in your browser using DataLab