What is the difference between Pipeline([('scaler', StandardScaler()), ('clf', LogisticRegression())]) and make_pipeline(StandardScaler(), LogisticRegression()) in scikit-learn?
Select an answer to reveal the explanation.
Short Explanation and Infographic
make_pipeline is just a convenience wrapper — it builds the same Pipeline but names the steps automatically (standardscaler, logisticregression) so you don't have to type the names yourself.
Full explanation below image
Full Explanation
Pipeline([('scaler', StandardScaler()), ('clf', LogisticRegression())]) — requires explicit step names (used to access steps: pipeline['scaler'] or pipeline.named_steps['scaler'], and to set hyperparameters in GridSearchCV: {'clf__C': [0.1, 1.0]}). make_pipeline(StandardScaler(), LogisticRegression()) — auto-generates lowercase class names: 'standardscaler' and 'logisticregression'. Hyperparameter access: {'logisticregression__C': [0.1, 1.0]}. Functionally identical: both create a Pipeline object with the same behavior (fit, transform, predict, cross_val_score). Both are equally compatible with GridSearchCV, cross_val_score, etc. Prefer Pipeline with explicit names when: you need memorable step names, you have multiple steps of the same class, or readability matters. Use make_pipeline when you want concise code and don't need to reference steps by name.