Created
October 13, 2021 17:19
-
-
Save liannewriting/5900a4113a9a3b2815af2f21df32e19c 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_negative = df_train['Class'] == 0 | |
msk_positive = df_train['Class'] == 1 | |
df_negative_undersample = df_train[msk_negative].sample(n=msk_positive.sum(), random_state=888) | |
df_train_undersample = pd.concat([df_negative_undersample, df_train[msk_positive]]) | |
df_train_undersample['Class'].value_counts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment