我正在尝试使用libsvm(使用Matlab接口)来运行一些多标签分类问题。以下是使用IRIS数据的一些玩具问题:
load fisheriris;
featuresTraining = [meas(1:30,:); meas(51:80,:); meas(101:130,:)];
featureSelectedTraining = featuresTraining(:,1:3);
groundTruthGroupTraining = [species(1:30,:); species(51:80,:); species(101:130,:)];
[~, ~, groundTruthGroupNumTraining] = unique(groundTruthGroupTraining);
featuresTesting = [meas(31:50,:); meas(81:100,:); meas(131:150,:)];
featureSelectedTesting = featuresTesting(:,1:3);
groundTruthGroupTesting = [species(31:50,:); species(81:100,:); species(131:150,:)];
[~, ~, groundTruthGroupNumTesting] = unique(groundTruthGroupTesting);
% Train the classifier
optsStruct = ['-c ', num2str(2), ' -g ', num2str(4), '-b ', 1];
SVMClassifierObject = svmtrain(groundTruthGroupNumTraining, featureSelectedTraining, optsStruct);
optsStruct = ['-b ', 1];
[predLabelTesting, predictAccuracyTesting, ...
predictScoresTesting] = svmpredict(groundTruthGroupNumTesting, featureSelectedTesting, SVMClassifierObject, optsStruct);
然而,对于我所获得的预测概率(这里显示的前12行结果)
1.08812899093155 1.09025554950852 -0.0140009056912001
0.948911671379753 0.947899227815959 -0.0140009056926024
0.521486301840914 0.509673405799383 -0.0140009056926027
0.914684487894784 0.912534150299246 -0.0140009056926027
1.17426551505833 1.17855350325579 -0.0140009056925103
0.567801459258613 0.557077025701113 -0.0140009056926027
0.506405203427106 0.494342606399178 -0.0140009056926027
0.930191457490471 0.928343421250020 -0.0140009056926027
1.16990617214906 1.17412523596840 -0.0140009056926026
1.16558843984163 1.16986137054312 -0.0140009056926015
0.879648874624610 0.876614924593740 -0.0140009056926027
-0.151223818963057 -0.179682730685229 -0.0140009056925999
我很困惑,一些概率是如何大于1而其中一些是否定的?
然而,预测的标签似乎非常准确:
1
1
1
1
1
1
1
1
1
1
1
3
最终输出
Accuracy = 93.3333% (56/60) (classification)
然后如何解释预测概率的结果?非常感谢。甲
答案 0 :(得分:2)
svm的输出不是概率!
分数符号表示它是属于A类还是B类。如果分数为1或-1,则它在边缘上,尽管知道这一点并不特别有用。
如果您确实需要概率,可以使用Platt scaling转换它们。你基本上对它们应用了sigmoid函数。
答案 1 :(得分:1)
我知道这个答案可能为时已晚,但它可能会让人们遇到同样的问题。
libsvm
实际上可以产生概率,使用选项'-b'。
我认为你犯的错误就是你定义optsStruct
变量的方式。它应该这样定义:['-b ' num2str(1)]
或['-b 1']
。
这同样适用于发送到svmtrain
的选项。