I'm using Caret to apply a bunch of different machine learning algorithms for phenotype prediction from gene expression data. With about 20,000 genes, I'd like to perform filter feature selection before training my classifiers. How can this be achieved? I've been through all the Caret documentation and vignettes, but the sbf and rfe feature selection methods seem to have the classification algorithms built in, for example
output = sbf(x,y,sbfControl = sbfControl(rfSBF, method = "repeatedcv", repeats = 5))
gets me a list of features for each fold and repeat, optimized according to the RF classifier accuracy.
Ideally, I'd like to pass the features selected in each fold along with the indices used into the "train" function, so that I'm only training on a small feature subset for each fold and repeat. The steps I want are:
- Split data into 10 folds
- Select features using 9 folds
- Train model on the same 9 folds and feature subset from step 2
- Evaluate performance on remaining fold
- Repeat 2-4 over all folds
- Repeat 1-5 with different fold splits
The "train" function takes care of everything but step 2 internally, so I can't figure out how to insert the feature selection using the same fold split. I assure you I've been through all the documentation I can find, so any other help would be much appreciated!