Very different results using fitcsvm/predict compared to svmtrain/svmclassify in same conditions. Why?

2 次查看(过去 30 天)
Although Matlab fitcsvm documentation says: “fitcsvm and svmtrain use, among other algorithms, SMO for optimization. The software implements SMO differently between the two functions, but numerical studies show that there is sensible agreement in the results.”
I am getting very different results using svmtrain/svmclassify and fitcsvm/predict for the exactly same datasets both using ‘SMO’ solver.
Fitcsvm/predict presents a much better classification then svmtrain/svmclassify results. Results of fitcsvm are a little better for ‘ISDA’ than ‘SMO’.
As I used to use in my applications svmtrain in Matlab 2014a, I was very confident on the results. Can I be confident on the results of fitcsvm with Matlab2015a? What has changed that explains those results?
Accuracy Recall C1 Recall C2 Precision C1 Precision C2 F1Measure C1 F1Measure C2
svmtrain(SMO) / svmclassify
50,10% 100,00% 0,39% 50,00% 100,00% 66,67% 0,78%
72,60% 87,11% 58,04% 67,58% 81,77% 76,11% 67,89%
62,62% 95,29% 30,08% 57,58% 86,52% 71,79% 44,64%
51,66% 99,22% 3,92% 50,90% 83,33% 67,29% 7,49%
fitcsvm(SMO) / predict
72,99% 87,45% 58,59% 67,78% 82,42% 76,37% 68,49%
76,91% 92,97% 60,78% 70,41% 89,60% 80,14% 72,43%
76,13% 90,20% 62,11% 70,34% 86,41% 79,04% 72,27%
72,41% 87,50% 57,26% 67,27% 82,02% 76,06% 67,44%
if metd == 1
Class_Model = svmtrain_Training (Fold1, ClassReal1, 1e-5
, 1e7);
elseif metd == 2
Class_Model = fitcsvm_Training (Fold1, ClassReal1, 1e-5
, 1e7, 'ISDA');
elseif metd == 3
Class_Model = fitcsvm_Training (Fold1, ClassReal1, 1e-5
, 1e7, 'SMO');
if metd == 1
[ClassPred2, ConfMtx] = svmclassify_Test (Class_Model, Fold2, ClassReal2);
elseif (metd == 2) || (metd == 3)
[ClassPred2, ConfMtx] = predict_Test (Class_Model, Fold2, ClassReal2);
function SVM_Model = fitcsvm_Training (TrainFeatMtx, ClassReal, tolkkt, itlim, solver)
SVM_Model = fitcsvm(TrainFeatMtx, ClassReal, ...
'CrossVal', 'off', ...
'IterationLimit', itlim, ...
'KernelFunction', 'linear', ...
'KernelScale', 'auto', ...
'KKTTolerance', tolkkt, ...
'Standardize', true, ...
'OutlierFraction', 0.0001, ...
'Solver', solver);
end
function [ClassPred, ConfMtx] = predict_Test (SVM_Model, FeatMtx, ClassReal)
ClassPred = predict(SVM_Model, FeatMtx);
ConfMtx = confusionmat(ClassReal, ClassPred);
end
function SVM_Model = svmtrain_Training (TrainFeatMtx, ClassReal, tolkkt, itlim)
optSVM = statset('MaxIter', itlim);
SVM_Model = svmtrain(TrainFeatMtx, ClassReal, ...
'kernel_function', 'linear', 'options', optSVM, 'tolkkt', tolkkt);
end
function [ClassPred, ConfMtx] = svmclassify_Test (SVM_Model, FeatMtx, ClassReal)
ClassPred = svmclassify(SVM_Model, FeatMtx);
ConfMtx = confusionmat(ClassReal, ClassPred);
end
If necessary I can send datasets used on the 4 tests.

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by