WrapUp Quiz - Q6 Error

Hi. I’m trying to answer the Question 6 from the WrapUp Quiz, but I’m getting an error all the time I run. When I try to run a cross validation, this error is showing.

(the error was repeated 5 times, all the same, and the “categorical_columns” and "numerical-features’ variables are both lists.)

The error is due to the line:

("num-preprocessor", StandardScaler(), SimpleImputer(), numerical_features)

You are expecting that by passing several transformers scikit-learn will pipeline them. However, scikit-learn is not that smart :slight_smile:

You will need to be explicit and to create the pipeline

("num-preprocessor", make_pipeline(StandardScaler(), SimpleImputer()), numerical_features)

Be aware that you have the same issue for the categorical part as well.

I am just recalling the hint that is given in the exercise for this question:

scaler_imputer_transformer = make_pipeline(StandardScaler(), SimpleImputer())
preprocessor = ColumnTransformer(transformers=[
    ("num-preprocessor", scaler_imputer_transformer, numerical_features)
])
model = make_pipeline(preprocessor, LogisticRegression())

Observe that scaler_imputer_transformer is indeed a scikit-learn Pipeline and not just a list of transformers.

The error was repeated for each round of the cross-validation when you call cross_validate.

It works! Thank you so much!