[英]Is there a way to find the average precision and recall of each class in the custom Tensorflow model?
[英]What is the best way to train your model and favoring recall/precision?
我有一个二进制分类问题,我的数据集由5%的正向标签组成。 我正在使用张量流训练我的模型。 这是我在训练期间的结果:
Step 3819999: loss = 0.22 (0.004 sec)
Accuracy = 0.955; Recall = 0.011; Precision = 0.496
Step 3820999: loss = 0.21 (0.003 sec)
Accuracy = 0.955; Recall = 0.011; Precision = 0.496
Step 3821999: loss = 0.15 (0.003 sec)
Accuracy = 0.955; Recall = 0.011; Precision = 0.496
Step 3822999: loss = 0.15 (0.003 sec)
Accuracy = 0.955; Recall = 0.011; Precision = 0.496
改善召回率的主要策略是什么? 更改数据集并添加更多肯定标签可能可以解决问题,但是更改问题的实际情况似乎很奇怪。
以我的观点,应该有一种方法支持“真肯定”而不是“假否定”,但是我似乎找不到。
您应该使用“ 加权交叉熵 ”代替经典的CE。 从Tensorflow文档中:
类似于sigmoid_cross_entropy_with_logits(),不同之处在于pos_weight可通过相对于负误差增加或减小正误差的成本来权衡取回和精度。 通常的交叉熵成本定义为:
targets * -log(sigmoid(logits)) + (1 - targets) * -log(1 - sigmoid(logits))
值pos_weights> 1会减少假阴性计数,从而增加召回率。 相反,将pos_weights设置为<1可减少误报计数并提高精度。 从以下事实可以看出这一点:pos_weight作为损失表达式中正目标项的乘数系数引入:
targets * -log(sigmoid(logits)) * pos_weight + (1 - targets) * -log(1 - sigmoid(logits))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.