cvpartition with different selection of input features per fold

2 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by