SelectKBest is configured with score_func=chi2 and fitted on a design matrix that contains negative values. What happens?
Correct answer
A. It raises an error, because chi-squared scoring needs non-negative features
18 views
A. It raises an error, because chi-squared scoring needs non-negative features
18 views
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.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is A? Ask here and get an explanation.