Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
python imbalanced data machine learning classification
msk = df_train['Class'] == 1
num_to_oversample = len(df_train) - 2*msk.sum()
df_positive_oversample = df_train[msk].sample(n=num_to_oversample, replace=True, random_state=888)
df_train_oversample = pd.concat([df_train, df_positive_oversample])
df_train_oversample['Class'].value_counts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment