2013-03-20 55 views
1

真阳性的确切数字在WEKA,我可以很容易地找到TP率和混淆矩阵总真分类实例,但有什么办法,看看TP和/或TN的确切数字?找到秧鸡

你知道有什么方法在matlab-anfis中查找这些值吗?

回答

1

既然你提到MATLAB,我假设你正在使用Weka库的Java API以编程方式构建分类器。

在这种情况下,您可以使用weka.classifiers.Evaluation类来评估模型,该类提供各种统计信息。

假设你已经有了Java类路径上weka.jar文件(见javaaddpath功能),这里是在MATLAB一个例子:

%# data 
fName = 'C:\Program Files\Weka-3-7\data\iris.arff'; 
loader = weka.core.converters.ArffLoader(); 
loader.setFile(java.io.File(fName)); 
data = loader.getDataSet(); 
data.setClassIndex(data.numAttributes()-1); 

%# classifier 
classifier = weka.classifiers.trees.J48(); 
classifier.setOptions(weka.core.Utils.splitOptions('-C 0.25 -M 2')); 
classifier.buildClassifier(data); 

%# evaluation 
evl = weka.classifiers.Evaluation(data); 
pred = evl.evaluateModel(classifier, data, {''}); 

%# display 
disp(classifier.toString()) 
disp(evl.toSummaryString()) 
disp(evl.toClassDetailsString()) 
disp(evl.toMatrixString()) 

%# confusion matrix and other stats 
cm = evl.confusionMatrix(); 

%# number of TP/TN/FP/FN with respect to class=1 (Iris-versicolor) 
tp = evl.numTruePositives(1); 
tn = evl.numTrueNegatives(1); 
fp = evl.numFalsePositives(1); 
fn = evl.numFalseNegatives(1); 

%# class=XX is a zero-based index which maps to the following class values 
classValues = arrayfun(@(k)char(data.classAttribute.value(k-1)), ... 
    1:data.classAttribute.numValues, 'Uniform',false); 

输出:

J48 pruned tree 
------------------ 

petalwidth <= 0.6: Iris-setosa (50.0) 
petalwidth > 0.6 
| petalwidth <= 1.7 
| | petallength <= 4.9: Iris-versicolor (48.0/1.0) 
| | petallength > 4.9 
| | | petalwidth <= 1.5: Iris-virginica (3.0) 
| | | petalwidth > 1.5: Iris-versicolor (3.0/1.0) 
| petalwidth > 1.7: Iris-virginica (46.0/1.0) 

Number of Leaves :  5 

Size of the tree : 9 


Correctly Classified Instances   147    98  % 
Incorrectly Classified Instances   3    2  % 
Kappa statistic       0.97 
Mean absolute error      0.0233 
Root mean squared error     0.108 
Relative absolute error     5.2482 % 
Root relative squared error    22.9089 % 
Coverage of cases (0.95 level)   98.6667 % 
Mean rel. region size (0.95 level)  34  % 
Total Number of Instances    150  

=== Detailed Accuracy By Class === 

       TP Rate FP Rate Precision Recall F-Measure MCC  ROC Area PRC Area Class 
       1.000 0.000 1.000  1.000 1.000  1.000 1.000  1.000  Iris-setosa 
       0.980 0.020 0.961  0.961 0.961  0.955 0.990  0.969  Iris-versicolor 
       0.960 0.010 0.980  0.980 0.980  0.955 0.990  0.970  Iris-virginica 
Weighted Avg. 0.980 0.010 0.980  0.980 0.980  0.970 0.993  0.980  

=== Confusion Matrix === 

    a b c <-- classified as 
50 0 0 | a = Iris-setosa 
    0 49 1 | b = Iris-versicolor 
    0 2 48 | c = Iris-virginica 
相关问题