Learn R Programming

SMOTEWB (version 1.2.0)

ROS: Random Oversampling (ROS)

Description

Resampling with ROS.

Usage

ROS(x, y)

Value

a list with resampled dataset.

x_new

Resampled feature matrix.

y_new

Resampled target variable.

Arguments

x

feature matrix.

y

a factor class variable with two classes.

Author

Fatih Saglam, saglamf89@gmail.com

Details

Random Oversampling (ROS) is a method of copying and pasting of positive samples until balance is achieved.

Can work with classes more than 2.

Examples

Run this code

set.seed(1)
x <- rbind(matrix(rnorm(2000, 3, 1), ncol = 2, nrow = 1000),
           matrix(rnorm(100, 5, 1), ncol = 2, nrow = 50))
y <- as.factor(c(rep("negative", 1000), rep("positive", 50)))

plot(x, col = y)

# resampling
m <- ROS(x = x, y = y)

plot(m$x_new, col = m$y_new)

Run the code above in your browser using DataLab