def get_sen_spe(SR, GT, threshold=0.8):
Sen = 0.0
Sep = 0.0
SR = SR > threshold
GT = GT > threshold
TP = ((SR == 1).byte() + (GT == 1).byte()) == 2
FP = ((SR == 1).byte() + (GT == 0).byte()) == 2
TN = ((SR == 0).byte() + (GT == 0).byte()) == 2
FN = ((SR == 0).byte() + (GT == 1).byte()) == 2
Sen = float(sum(TP)) / (float(sum(TP + FN)) + 1e-6)
Sep = float(sum(TN)) / (float(sum(TN + FP)) + 1e-6)
YD_index = Sen + Sep -1
PPV = float(sum(TP)) / (float(sum(TP + FP)) + 1e-6)
NPV = float(sum(TN)) / (float(sum(TN + FN)) + 1e-6)
return Sen, Sep, PPV, NPV, YD_index
| 真实 |
预测 |
| 阳T |
阴F |
| 阳T |
TP |
FN |
| 阴F |
FP |