How to create matrix for leave-one-out-cross validation?
Show older comments
I have dataset that turned into 3500x400 matrix. I want to apply leave one out cross validation. But i cant seem to generate the right train-matrix. Please help.
mix=randperm(3500);
for i=1:10% divide into 10sets of 350 rows each
test = mix(1+350*(i-1):350*i);
train = mix([1+350*(i-2):350*(i+1)-1 350*(i+1):3500]);
train_labels = Labels(train);
test_labels = Labels(test);
%train model
nb(i) = fitcnb(traina, train_labels,'DistributionNames','mn');
y(i) = predict(nb,test);
%Check if prediction was correct
accuracy(i) = test_labels/350;
end
Answers (0)
Categories
Find more on Function Definition in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!