cvpartition with different selection of input features per fold
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am currently utilizing cvpartition to perform k-fold cross validation.
A simplified code I am using looks like below:
% create cross validation object
cvo = cvpartition(y, 'KFold', 5); % 5-fold cross validation
% perform cross validation using logistic regression
logisticRegression = fitglm(x, y, 'CVPartition', cvo, 'ClassNames', classOrder);
The issue I have is that I now want to perform some feature selection only using the training fold of each cross validation split to prevent data leakage (using some statistics from the training data in order to select which features to use for model training).
Procedure (very rough pseudo code) for what I am describing above looks like below:
create cvo
for each fold f:
perform feature selection using training portion of the fold (using some stats calculated based on the training portion of the fold)
train the model with reduced set of features
evaluate (validate) the model using the validation portion of the fold
end
Is there a way achieve above (using different feature subsets for each fold) with cvo? I have already built a pretty extensive pipeline around using cvo, so I'd like to keep using it to prevent myself from re-doing most of the work.
Any help will be greatly appreciated. Thank you,
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!