Effacer les filtres
Effacer les filtres

cvpartition with different selection of input features per fold

2 vues (au cours des 30 derniers jours)
Louis
Louis le 23 Jan 2023
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,

Réponses (0)

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by