多分类器one-against-rest模式的使用

shizhiniepan 2016-12-24 09:32:23
之前没做过one-against-rest的模式,都是直接调用libsvm中的svmtrain和svmpedict,今天仿真论文说分类用这种策略然后按照下面的代码改了一下自己的代码,运行的结果却不明白其中的意思,想问下大家有没有用过这种策略麻烦给我说一下,谢谢!
%# Fisher Iris dataset
load fisheriris
[~,~,labels] = unique(species); %# labels: 1/2/3
data = zscore(meas); %# scale features
numInst = size(data,1);
numLabels = max(labels);

%# split training/testing
idx = randperm(numInst);
numTrain = 100; numTest = numInst - numTrain;
trainData = data(idx(1:numTrain),:); testData = data(idx(numTrain+1:end),:);
trainLabel = labels(idx(1:numTrain)); testLabel = labels(idx(numTrain+1:end));
%# train one-against-all models
model = cell(numLabels,1);
for k=1:numLabels
model{k} = svmtrain(double(trainLabel==k), trainData, '-c 1 -g 0.2 -b 1');
end

%# get probability estimates of test instances using each model
prob = zeros(numTest,numLabels);
for k=1:numLabels
[~,~,p] = svmpredict(double(testLabel==k), testData, model{k}, '-b 1');
prob(:,k) = p(:,model{k}.Label==1); %# probability of class==k
end

%# predict the class with the highest probability
[~,pred] = max(prob,[],2);
acc = sum(pred == testLabel) ./ numel(testLabel) %# accuracy
C = confusionmat(testLabel, pred) %# confusion matrix

改完我的代码运行的结果:
optimization finished, #iter = 230
nu = 0.256314
obj = -63.992449, rho = -0.828822
nSV = 188, nBSV = 72
Total nSV = 188
Accuracy = 97.6852% (211/216) (classification)
Accuracy = 95.8333% (207/216) (classification)
Accuracy = 99.537% (215/216) (classification)
Accuracy = 87.5% (189/216) (classification)
Accuracy = 88.4259% (191/216) (classification)
Accuracy = 95.8333% (207/216) (classification)
Accuracy is 0.90%
不知道这些参数是什么意思?麻烦讲一下。。。

...全文
359 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3,423

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 其他开发语言
社区管理员
  • 其他开发语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧