Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created August 19, 2020 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/77133b5e05c36ae582dbd00d58beb209 to your computer and use it in GitHub Desktop.
Save amankharwal/77133b5e05c36ae582dbd00d58beb209 to your computer and use it in GitHub Desktop.
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