What is the general procedure for a combined task of model tuning (i.e., hyperparameter selection), feature selection and model selection?
I know some basic principles for each task, but when combining them all together, I am confused.
For example, let's assume we have 1000 features to be selected from (already filtered after unsupervised methods) and 1000 samples, and the output labels are True/False binary outcome.
The candidate models considered here are k-nearest neighbors (KNN) model, and Support Vector Machines (SVM) with Linear Kernel, so the hyperparameters are the number of neighbors (k) in KNN and the cost (C) in SVM.
We would like to use the genetic algorithm (GA) to guide the search, and cross-validation to tune the hyperparameters during the search process.
Is the following procedure correct?
The following procedure 1 to 6 runs for each of the candidate models (i.e., KNN and SVM), individually:
- Randomly choose 100 samples to be the test set (holdout).
- Create 10 folds on the remaining 900 samples, use 9 folds (i.e., 810 samples) as train data for GA search, and 1 fold (i.e., 90 samples) for fitness evaluation.
- In each GA generation, for each child, the hyperparameters are tuned using cross-validation on the 810 samples (i.e., model fitting and evaluation are performed solely on the 810 samples). The fitness of the tuned model is evaluated using the 90 samples. Based on the fitness value, the next generation is produced. This process continues until stopping criteria is met. Record the number of generations that takes to reach the stopping criteria. (This is what I understood from the CARET package documentation)
- Repeat step 3, with using another fold (another 90 samples) for fitness evaluation, and the rest (810 samples) for GA search. Until all the samples have been used for fitness evaluation.
- Determine the optimal number of generations, based on the resampling result of step 3 to 4. Using all the 900 samples, and run GA again for the optimal generation to get the final model, model fitness is evaluated on the 100 holdout sample, the hyperparameters are tuned using cross-validation on the 900 sample. The predictor subset is associated with the optimal number of generations and the search behavior of GA, and thus can be different in different GA runs.
- The final model performance is evaluated on the 100 holdout sample. And step 1-5 can be resampling many times to get the range of model performance.
Build a KNN model and a SVM model using steps 1 to 6, and the best model is selected using the statistics obtained in step 6.
The above procedure looks very complex, and the result is uncertain because the final feature selected by GA can be different in different runs. Is there another way to do the above tasks (combined feature selection, model tuning and model comparison)?
I did not use recursive feature elimination methods (e.g., backwards selection), because some of the predictors are correlated, and removing correlated predictors can cause loss of information in this particular problem. So I think GA search is more flexible, and thus is more suitable for the correlated predictors. Is it right?