1. Home
  2. Data Science
  3. Scikit-learn
  4. SelectKBest is configured with score_func=chi2 and fitted…

Added 30 Nov -0001

SelectKBest is configured with score_func=chi2 and fitted on a design matrix that contains negative values. What happens?

  1. It raises an error, because chi-squared scoring needs non-negative features Correct answer
  2. It silently takes absolute values before computing the chi-squared scores
  3. It works but ranks the negative features last regardless of their true signal
  4. It standardises the features first, which makes every value non-negative

Correct answer

A. It raises an error, because chi-squared scoring needs non-negative features

18 views

MCQSEXAM

Explanation

chi2 is defined for counts, so SelectKBest raises a ValueError when X contains negative entries instead of producing a score. Standardising or otherwise centring the data therefore breaks chi-squared feature selection, and f_classif or mutual_info_classif are the usual replacements. MinMaxScaler can make features non-negative, but the resulting scores then describe shifted data rather than counts.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

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