# Selecting Transforms with sklearn pipelines

So I am currently working on a Data set, and I want to use Pipelines to select the transforms. Here is an example of what I want to do :

# I missed the imports just for brevity
pipeline = make_pipeline(StandardScaler(), PolynomialFeatures(), PCA(), LogisticRegression())


So what I want to do, I want to try both StandardScaler, MinMaxScaler and no scaler when I am using other methods such as XGBOOST. Then I want to try to use polynomial features and then use a PCA, only if I used polynomial features. And finally, I want to try Logistic Regression and XGBOOST with GridSearch (This last part I know how to do).

Anybody did something similar? Thank you!

The purpose of the pipeline is to assemble several steps that can be cross-validated together while setting different parameters. For this, it enables setting parameters of the various steps using their names

Check the docs

For your requirement, you will have to create multiple pipelines, you cannot do it via single pipeline.

• Yeah I am aware of what the documentation says. I was wondering if someone had an elegant solution for this anyway. Aug 21 '20 at 11:12

There is an example of this here:

https://iaml.it/blog/optimizing-sklearn-pipelines

• How do you make it to accept your own answers as the accepted one? Sep 2 '20 at 21:10
• I just clicked on the tick on the left why? Sep 2 '20 at 21:15