在matlab中训练模型时,在1/4迭代中缺少类

问题描述 投票:-1回答:1
e= load('data')

k=5; f=12;

n=e.n(:,1:12);

data=n(randsample(1:length(n),length(n)),:);

truth=n(:,features+1);

c = cvpartition(truth,'KFold',k)

for i= 1:k

    trIdx = c.training(i);

    teIdx = c.test(i);

    Model = fitcecoc(data(trIdx,:),truth(trIdx,:))

    [class,s]= predict (Model,data(teIdx,:));

end 

Model = fitcecoc(data(trIdx,:),truth(trIdx,:))在for循环完成任何迭代过程中类的模型缺失之后。

i.e1st iteration期间,模型具有4个类名(因为我的数据最初为ha)但在2nd iteration或其他迭代中,分类器会错过或忽略一个类别。

给出[1 3 4]而不是[1 2 3 4]

matlab svm
1个回答
0
投票

@@ Hussain Ahmad,请检查有关K折交叉验证的内容,https://machinelearningmastery.com/k-fold-cross-validation

© www.soinside.com 2019 - 2024. All rights reserved.