Solved – Understanding cross-validated recursive feature elimination

feature selectionmachine learningoptimization

I want to understand the algorithm of recursive feature eliminiation (RFE) combined with crossvalidation (CV). An original source by Guyon et al. on RFE can be found here.

  • My understanding of RFE: We train our classifier – say a linear Support Vector Machine – first with all features. This gives us a weight for each feature. The absolute value of these weights reflects the importance of each feature. We remove the least important feature, perform again a training, get a new ranking and continue so on until we have ranked all our features

  • My question: I am running RFE cross-validated (in python with this implementation). In the example below, several features are ranked first. How does this come about? For a final ranking I assume that the RFE elimination has to be done repeatedly, so does this imply several applications of RFE where each time another feature has been ranked first? How is this combined with cross-validation, and how then is the (see plot below) classification accuracy from 1,2,3,..features calculated, when each of these subsets could consist of different features?

enter image description here

Best Answer

Say you run a 3-fold RFECV. For each split, the train set will be transformed by RFE n times (for each possible 1..n number of features). The classifier supplied will be trained on the training set, and a score will be computed on the test set. Eventually, for each 1..n number of features, the mean result from the 3 different splits is shown on the graph you included. Then, RFEVC transforms the entire set using the best scoring number of features. The ranking you see is based on that final transformation.

Related Question