Over sampling

from imblearn.over_sampling import RandomOverSampler

ros = RandomOverSampler(random_state=42)

x_ros, y_ros = ros.fit_resample(XY.iloc[:, :-1], XY.loc[:, 'label'])
print('Original dataset shape:', Counter(y))
print('Original dataset shape:', Counter(y_ros))

XY = pd.concat([x_ros, y_ros], axis=1)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s