Skip to content

Instantly share code, notes, and snippets.

@wmlba
Last active April 21, 2019 16:02
Show Gist options
  • Save wmlba/b20a44e7d1f86d7cfc3cfeac8a9c77a7 to your computer and use it in GitHub Desktop.
Save wmlba/b20a44e7d1f86d7cfc3cfeac8a9c77a7 to your computer and use it in GitHub Desktop.
from imblearn.over_sampling import SMOTE
# Resample the minority class. You can change the strategy to 'auto' if you are not sure.
sm = SMOTE(sampling_strategy='minority', random_state=7)
# Fit the model to generate the data.
oversampled_trainX, oversampled_trainY = sm.fit_sample(credit_df.drop('Class', axis=1), credit_df['Class'])
oversampled_train = pd.concat([pd.DataFrame(oversampled_trainY), pd.DataFrame(oversampled_trainX)], axis=1)
oversampled_train.columns = normalized_df.columns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment