Repository navigation
Expand file tree
/
Copy patheval_pred.py
More file actions
47 lines (37 loc) · 1.41 KB
/
Copy patheval_pred.py
File metadata and controls
47 lines (37 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pandas as pd
from sklearn.metrics import confusion_matrix, roc_auc_score
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.metrics import roc_curve
if __name__=='__main__':
data = pd.read_csv('revised/BraTS_pred_Focus_loss_dual.csv')
gt = data['mgmt_truth']
pred = data['pred_class']
confusion = confusion_matrix(gt, pred)
TP = confusion[1, 1]
TN = confusion[0, 0]
FP = confusion[0, 1]
FN = confusion[1, 0]
print('AUC:', roc_auc_score(gt, pred))
print('Accuracy:', (TP + TN) / float(TP + TN + FP + FN))
print('Sensitivity:', TP / float(TP + FN))
print('Specificity:', TN / float(TN + FP))
print('PPV:', TP / float(TP + FP))
print('Recall:', TP / float(TP + FN))
print('Precision:', TP / float(TP + FP))
ax = sns.heatmap(confusion,
cmap="YlGnBu",
annot=True,
linewidths=2,
square=True,
xticklabels=['Negative', 'Positive'],
yticklabels=['Negative', 'Positive'], )
ax.set_title('confusion matrix', family='Arial')
plt.show()
fpr, tpr, threshold = roc_curve(gt, data['pred'], pos_label=1)
plt.xlabel('False Positive Rate')
plt.ylabel('Ture Positive Rate')
plt.title('roc curve')
plt.plot(fpr, tpr)
plt.plot([0, 1], [0, 1], 'r--')
plt.show()