QuestionQ134

VerifiedData Processing

A data scientist is developing a logistic-regression model with sklearn pipelines. They currently use the following code, which handles only numeric features:

Question Image

The data scientist needs to update the pipeline so it handles both numeric and categorical features.

Which code block accomplishes this?

Explanation

ColumnTransformer applies separate transformers to specified subsets of columns and concatenates their outputs. A numeric pipeline can therefore mean-impute and standardize numeric columns, while a categorical pipeline can most-frequent-impute and one-hot encode categorical columns; the combined result is then passed to LogisticRegression.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!