Skip to content

Instantly share code, notes, and snippets.

@amankharwal

amankharwal/class_balancing.py Secret

Created Apr 25, 2021
Embed
What would you like to do?
# Resampling with Replacement
import numpy as np
from sklearn.utils import resample
x_resampled = resample(x[y==1], n_samples=x[y==0].shape[0], random_state=1000)
x_ = np.concatenate((x[y==0], x_resampled))
y_ = np.concatenate((y[y==0], np.ones(shape=(x[y==0].shape[0],), dtype=np.int32)))
print(x_[y_==0].shape)
print(x_[y_==1].shape)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment