Lan*_*pel 2 machine-learning weka precision-recall
我是WEKA的新手和高级统计数据,从头开始了解WEKA措施.我已经完成了所有@ rushdi-shams示例,这些都是很好的资源.
在维基百科上,http://en.wikipedia.org/wiki/Precision_and_recall示例解释了一个简单的例子,关于在一组9只真正的狗和一些猫中检测7只狗的视频软件.我完全理解这个例子和召回计算.所以我的第一步,让我们看看Weka如何使用这些数据进行再现.我如何创建这样的.ARFF文件?有了这个文件我有一个错误的混淆矩阵,并且错误的精确度按类召回不是1,它应该是4/9(0.4444)
@relation 'dogs and cat detection'
@attribute 'realanimal' {dog,cat}
@attribute 'detected' {dog,cat}
@attribute 'class' {correct,wrong}
@data
dog,dog,correct
dog,dog,correct
dog,dog,correct
dog,dog,correct
cat,dog,wrong
cat,dog,wrong
cat,dog,wrong
dog,?,?
dog,?,?
dog,?,?
dog,?,?
dog,?,?
cat,?,?
cat,?,?
Run Code Online (Sandbox Code Playgroud)
输出Weka(不带过滤器)
===运行信息===
Scheme:weka.classifiers.rules.ZeroR
Relation: dogs and cat detection
Instances: 14
Attributes: 3
realanimal
detected
class
Test mode:10-fold cross-validation
=== Classifier model (full training set) ===
ZeroR predicts class value: correct
Time taken to build model: 0 seconds
=== Stratified cross-validation ===
=== Summary ===
Correctly Classified Instances 4 57.1429 %
Incorrectly Classified Instances 3 42.8571 %
Kappa statistic 0
Mean absolute error 0.5
Root mean squared error 0.5044
Relative absolute error 100 %
Root relative squared error 100 %
Total Number of Instances 7
Ignored Class Unknown Instances 7
=== Detailed Accuracy By Class ===
TP Rate FP Rate Precision Recall F-Measure ROC Area Class
1 1 0.571 1 0.727 0.65 correct
0 0 0 0 0 0.136 wrong
Weighted Avg. 0.571 0.571 0.327 0.571 0.416 0.43
=== Confusion Matrix ===
a b <-- classified as
4 0 | a = correct
3 0 | b = wrong
Run Code Online (Sandbox Code Playgroud)
False Negative狗肯定有问题,或者我的ARFF方法完全错了,我还需要其他类型的属性吗?
谢谢
小智 6
让我们从Precision和Recall的基本定义开始.
Precision = TP/(TP+FP)
Recall = TP/(TP+FN)
Run Code Online (Sandbox Code Playgroud)
TP真阳性在哪里,FP是假阳性,FN是假阴性.
在上面的dog.arff文件中,Weka只考虑了前7个元组,忽略了剩下的7个.从上面的输出中可以看出它已经将所有7个元组分类为正确(4个正确的元组+ 3个错误的元组) ).
让我们计算正确和错误类的精度.首先是正确的课程:
Prec = 4/(4+3) = 0.571428571
Recall = 4/(4+0) = 1.
Run Code Online (Sandbox Code Playgroud)
对于错误的班级:
Prec = 0/(0+0)= 0
recall =0/(0+3) = 0
Run Code Online (Sandbox Code Playgroud)