# Caret: Feature selection with Chi2 / f_classif

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?