how to compare the class of input and output,and display the misclassification,how much percentage it is classified properly

10 vues (au cours des 30 derniers jours)
x1 x2 class
a= -1.7986 -1.6730 1.0000
-1.0791 -0.5937 1.0000
-0.5995 0.7556 1.0000
1.0791 -1.4032 1.0000
0.1199 0.2159 1.0000
0.3597 0.4857 -1.0000
-0.3597 1.5651 -1.0000
0.5995 0.4857 -1.0000
0.1199 -0.3238 -1.0000
1.5588 0.4857 -1.0000
result=x1 x2 wx-gamma class
-1.7986 -1.6730 0.8068 1.0000
-1.0791 -0.5937 0.3781 1.0000
-0.5995 0.7556 -0.0706 -1.0000
1.0791 -1.4032 0.1382 1.0000
0.1199 0.2159 -0.0808 -1.0000
0.3597 0.4857 -0.2004 -1.0000
-0.3597 1.5651 -0.3298 -1.0000
0.5995 0.4857 -0.2503 -1.0000
0.1199 -0.3238 0.0588 1.0000
1.5588 0.4857 -0.4500 -1.0000

Réponses (1)

Ahmed
Ahmed le 30 Sep 2014
To just get the accuracy it is only required to count the number of matches and divide by the total number of observations:
acc = sum(a.class == result.class)/size(a.class,1),
However, you should consider having a look at the confusion matrix as well:
cfMat = confusionmat(a.class,result.class),
acc = sum(diag(cfMat))/sum(cfMat(:)),
Then print the result nicely:
fprintf('Accuracy: %.1f%%\n',100*acc);
In addition, investigating some sort of performance curve is also helpful:
[FPR,TPR,~,AUC] = perfcurve(a.class, result.wx_gamma,1);
plot(FPR,TPR);
axis('equal');
axis([0 1 0 1]);
hold on; grid on;
line([0 1],[0 1]);
hold off;
xlabel('FPR'); ylabel('TPR');

Community Treasure Hunt

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

Start Hunting!

Translated by