Question 6 Error

Hi All,

I’m receiving this error when I try to run this code

from sklearn.compose import make_column_transformer

preprocessor = make_column_transformer(
(OneHotEncoder(handle_unknown=“ignore”), categorical_data),
(StandardScaler(), numerical_data))

model2 = make_pipeline(preprocessor, LogisticRegression(max_iter = 1000))

cv = cross_validate(model2, data, target, cv = 10)

ValueError: No valid specification of the columns. Only a scalar, list or slice of all integers or all strings, or boolean mask is allowed

Any one could help me with this?

1 Like

For debugging the error I would have to see your definitions of categorical_data and numerical_data. Still, make sure that the make_column_transformer requires the names of the columns and not the subset of the data corresponding to said columns (i.e. not a pandas frame).