I have a simple question and I'am not very familiar with matlab. so code would be very helpfull ;). I do have a KNN classifier which I want to evaluate via crossvalidation. My code looks like the following:
load ds
train_data= trainData';
train_target=trainLabels;
Num=size(3,3);
Smooth=0.2;
nfold=10
indices = crossvalind('Kfold',train_target,10);
for i = 1:nfold
test = (indices == i); train = ~test;
[Prior,PriorN,Cond,CondN]=KNNtr(train_data(train,:),train_target(train,:),Num,Smooth);
[HammingLoss,RankingLoss,OneError,Coverage,Average_Precision,Outputs,Pre_Labels] = KNNte(train_data(train,:),train_target(train,:),train_data(test,:),train_target(test,:),Num,Prior,PriorN,Cond,CondN);
end
My input data is for the labels 10000*1 and for the training_data 128*10000. Now, when I run the program it results in 1000*1 Pre_Labels or the other outputs as well. I guess this is because I only have 1 fold displayed. All I want is to have all outputs of all folds, in an ordered structure, displayed. How do I have to change my code to achieve this?
Thank you very much!! It's a great help