Skip to content

Instantly share code, notes, and snippets.

@srang992
Last active May 26, 2022 03:00
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 srang992/1b436b2f7dff380229eaf1061198f684 to your computer and use it in GitHub Desktop.
Save srang992/1b436b2f7dff380229eaf1061198f684 to your computer and use it in GitHub Desktop.
from collections import Counter
# splitting the data as X and y
X = tel_data_selected.drop('churn', axis=1)
y = tel_data_selected['churn']
# making a SMOTE object
resampler = SMOTE(random_state=5)
# splitting the data into train and test
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, stratify=y)
# resampling the data
X_resampled, y_resampled = resampler.fit_resample(X_train, y_train)
# verifying the resampled data
print('Resampled dataset shape %s' % Counter(y_resampled))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment