scikit-learn says chi squared test used for feature selection in classification problems and implemented by sklearn.feature_selection.chi2 requires the feature which it tests with the outcome to be nonnegative.

As I understand from Wikipedia, the chi squared independence test test independence between two discrete random variables with finite ranges from their joint samples. So the random variables can be categorical, positive, or nonnegative, as long as they are discrete and have finite ranges, i.e. we can create a contingency table from their joint samples.

So what features can the chi squared feature selection in scikit-learn apply to?


  • $\begingroup$ Yes, it does. Events are non-negative, and squares of real numbers are non-negative. $\endgroup$ – Carl Feb 15 '18 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.