1. Home
  2. Data Science
  3. Scikit-learn
  4. A column in the training data is entirely NaN. What does…

Added 30 Nov -0001

A column in the training data is entirely NaN. What does SimpleImputer(strategy='mean') do with it by default?

  1. It fills the column with zeros, because an undefined mean is replaced by zero
  2. It raises a ValueError, since no statistic at all can be computed from an empty column
  3. It keeps the column and fills it with NaN, preserving the missing-value marker
  4. It drops the column from the transformed output and ignores it during transform Correct answer

Correct answer

D. It drops the column from the transformed output and ignores it during transform

20 views

MCQSEXAM

Explanation

SimpleImputer discards features that contain only missing values when keep_empty_features is False, the default, so the output has fewer columns than the input. This silently shifts column positions, which is why inspecting get_feature_names_out or the ColumnTransformer mapping matters. Setting keep_empty_features=True retains the column filled with the fill value.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? 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