簡體   English   中英

如何在 tf.keras.metrics 中找到誤報率

[英]how to find false positive rate in tf.keras.metrics

我試圖找到誤報率。 我有誤報和真負值,我正在嘗試這行代碼

    # calculate false positives and negatives based on the predicted output vs. expected output
fp = tf.keras.metrics.FalsePositives()
fp.update_state(bigy[test], pred)
fn = tf.keras.metrics.FalseNegatives()
fn.update_state(bigy[test], pred)
tn = tf.keras.metrics.TrueNegatives()
tn.update_state(bigy[test], pred)
#Find flase positive rate.
# fpr = false postive rate, fp = false positive, tn is true negative.
fpr = fp/(fp+tn)
#FPR = FP/(FP+TN)

但它不起作用給我不支持的操作數類型錯誤。 我猜來自 tf.keras.metrics.TrueNagatives() 的值不正確 那么我如何計算假陽性率

根據docs ,您仍然必須對值調用.result().numpy()

fp = tf.keras.metrics.FalsePositives()
fp.update_state(bigy[test], pred)
fp = fp.result().numpy()

fn = tf.keras.metrics.FalseNegatives()
fn.update_state(bigy[test], pred)
fn = fn.result().numpy()

tn = tf.keras.metrics.TrueNegatives()
tn.update_state(bigy[test], pred)
tn = tn.result().numpy()

# Find false positive rate.
fpr = fp / (fp + tn)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM