Snippet of code not working: named_transformers_

The snippet of code in question 14 doesn’t work for me. Any idea why?

Most likely it’s because of how I defined my steps…

Thanks.

My code, with error:

After much tweaking, this works:

There must be a better way…

Hi Marc,
imho there´s no need to put a single encoder in a Pipeline().
I constructed my preprocessor like this and had no problem with the snippet.

numerical_features = data.select_dtypes(include='number').columns
categorical_features = data.select_dtypes(exclude='number').columns

preprocessor = make_column_transformer(
    (OneHotEncoder(handle_unknown='ignore'), categorical_features),
    (StandardScaler(), numerical_features))
1 Like

Yes, I realize that is the issue with my code and the snippet.

Although, as I am also taking the opportunity to learn some Python and its environment (Pandas, Numpy, Matplotlib), I prefer to write longer code and have “placeholders” so that, when I reuse / come back to this later on, I remember the “most complete” syntax / possibility.