您好我正在尝试使用matlab执行交叉验证。在每个折叠中,我应该有一个10x1向量,我想要连接这些向量。
最后,all_scores和all_labels必须是100x1大小,但我得到的是1000x1。任何人都知道以下代码中的问题是什么?
load iris.dat;
data=iris;
data( data(:,5)==3,:) = [];
labels=data(:,5);
indices = crossvalind('kfold',labels,10);
all_scores = [];
all_labels = [];
for i = 1:10
test = (indices==i);
train = ~test;
[IDX,scores] = knnsearch(train,test);
y =train(IDX);
all_scores = [all_scores; scores];
display(all_scores);
all_labels = [all_labels; y];
display(all_labels);
end