Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#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