I try to classify texts which I have converted to term-document matrices before. I would like to perform feature selection to reduce the number of predictors. In Python, you can do this by means of the SelectKBest function, for example like so:

selector = SelectKBest(f_classif, k = 2000)

The caret package from R also enables you to employ univariate feature selection; the tutorial section "Feature Selection using Univariate Filters" details the general approach here (https://topepo.github.io/caret/feature-selection-using-univariate-filters.html).

However, I do not understand this sufficiently to be able to build a Chi2 / f_classif feature selection on my own - how can this be achieved?


1 Answer 1


Your question isn't very clear about what exactly you wanted to do. That said, f_classif does ANOVA for feature selection for you instead of chi-squared.

R package FSelector provides chi squared feature selection with function chi.squared. Here is the example from the document: https://rdrr.io/cran/FSelector/man/chi.squared.html


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.