Created
October 13, 2021 16:00
-
-
Save liannewriting/8292d07b7cb853824d09496097b0acb9 to your computer and use it in GitHub Desktop.
python imbalanced data machine learning classification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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