Skip to content

Instantly share code, notes, and snippets.

@AllanLRH
Created January 6, 2020 10:16
Show Gist options
  • Save AllanLRH/b453749aff0bdd8d1d8346299d0d808e to your computer and use it in GitHub Desktop.
Save AllanLRH/b453749aff0bdd8d1d8346299d0d808e to your computer and use it in GitHub Desktop.
#resample #train_test_split
import imblearn
from sklearn import model_selection
rus = imblearn.under_sampling.RandomUnderSampler(sampling_strategy=1.0, random_state=42)
X, y = rus.fit_sample(df.drop('Target', axis=1), df.Target)
X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.33, random_state=42)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment