Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created August 19, 2020 11:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
from sklearn.utils import resample
train_majority = train_clean[train_clean.label==0]
train_minority = train_clean[train_clean.label==1]
train_minority_upsampled = resample(train_minority,
replace=True,
n_samples=len(train_majority),
random_state=123)
train_upsampled = pd.concat([train_minority_upsampled, train_majority])
train_upsampled['label'].value_counts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment