这是我第一次使用OpenCV中的机器学习功能。我使用了Boost算法,我认为它运作良好。然而,令人烦恼的是calc_error
函数只给出错误,而没有错误类型。我的意思是:
第一类错误:假阳性错误,误报
或者
第二类错误:漏检目标
OpenCV也能给出错误类型吗?非常感谢您。
回答:
在您的测试实例上使用predict
,遍历所有测试实例,并将结果与真实类别进行比较,以自己找出第一类/第二类错误(或精确度和准确度,这些在机器学习中更为常见的相关概念)。
表达这一想法的伪代码如下:
true_positive = 0false_positive = 0true_negative = 0false_negative = 0For i in 1..N: test_instance = test_set[i] true_class = labels[i] predicted_class = predict(test_instance, ... ) if true_class = True and predicted_class == True true_positive += 1 elseif true_class == False and predicted_class == True false_positive += 1 elseif true_class == True and predicted_class == False false_negative += 1 elseif true_class == False and predicted_class == False true_negative += 1 endtype_I_error = false_positive/Ntype_II_error = false_negative/N