1. Home
  2. Data Science
  3. Scikit-learn
  4. A ColumnTransformer applies OneHotEncoder to two columns…

Added 30 Nov -0001

A ColumnTransformer applies OneHotEncoder to two columns with remainder='passthrough'. What does the fitted output contain?

  1. Only numeric columns, since passthrough drops anything it cannot encode
  2. Encoded columns followed by every unlisted column appended unchanged in order Correct answer
  3. Only the encoded columns, because remainder='passthrough' keeps no other column at all
  4. The encoded columns plus a copy of the input frame, so all columns appear twice

Correct answer

B. Encoded columns followed by every unlisted column appended unchanged in order

18 views

MCQSEXAM

Explanation

ColumnTransformer concatenates the output of each transformer horizontally, then appends columns not named in any transformer when remainder='passthrough'; the default 'drop' removes them. Column order is the transformers' order followed by the remainder, which is why get_feature_names_out should be used instead of assuming positions. Setting remainder to an estimator applies it to the leftover columns.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Scikit-learn MCQs

Practise all Scikit-learn MCQs

Similar MCQs