leave one person out cross validation
8 次查看(过去 30 天)
显示 更早的评论
i have dataset which contains data from 10 subject. My idea fir cross validaytion is leave one person out cross validation. Here i trian on data from 9 subjects and test on data from 1. When we normally do cross validation, we have a stopping criteria which avoids model overfitting.
How do I avoid overfittiing in my case.
below is code snippet
for idx = 1:N%k = LOOCV train on rest; validate on K- meal
s = [1:idx-1 idx+1:N];
Xtrain= Training(s); %(all remaining datasets)
Xvalidate = Training(idx);% idx dataset
Xtrainlabel = Training_labels(s);
Xvalidatelabel = Training_labels(idx);
Mdl = fitcsvm(XTrain(:,featsel),...
XTrainlabel);
[trainSVM,trainScoreSVM] = resubPredict(Mdl); %training
%- Cross-validate the classifier
CVSVMModel = crossval( Mdl );
%validation
Yval_pred= predict(Mdl, XValidate(:, featsel)); %validation
[cmV,order] = confusionmat(Yval_pred, actual_val);
tnV = cmV(1,1);
fnV = cmV(1,2);
fpV = cmV(2,1);
tpV = cmV(2,2);
Accuracy(idx) = (tp+fp)./(tp+fp+tn+fn);
end
2 个评论
回答(1 个)
Prince Kumar
2021-9-7
You can try the following methods:
- Remove features
- Feature Selection
- Regularization
- Ensemble models if you are ok with trying models other than SVM
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Trees 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!