I am using the imblearn package to resample some data before applying other transformation/prediction techniques. Specfically, I am using SMOTE in a slightly unconventional way, as a data augmentation technique to upsample all classes rather than just the minority.
I would like to do a pipeline of SMOTE -> PCA -> SVM on data separated into training and test (most likely K-fold). However, consider the following snippet of code from the imblearn pipeline doccumentation:
pipeline = Pipeline([('smt', smt), ('pca', pca), ('knn', knn)])
X_train, X_test, y_train, y_test = tts(X, y, random_state=42)
pipeline.fit(X_train, y_train)
y_hat = pipeline.predict(X_test)
In the last line, it seems the test data will be resampled, which doesn't make sense -- only the training data should be resampled using this technique, or you will be testing on artificially generated data. The documentation for pipeline.predict() implies samplers are applied during prediction as well. Is there a way to avoid this, besides simply removing SMOTE from the pipeline?