[英]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.