-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
55 lines (45 loc) · 1.47 KB
/
utils.py
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
48
49
50
51
52
53
54
55
import numpy as np
import matplotlib.pyplot as plt
from sklearn import metrics
def plot_roc_binary(true, score, path, name):
for ix, (tr, sc) in enumerate(zip(true, score)):
fpr, tpr, thresholds = metrics.roc_curve(tr, sc)
plt.plot(fpr, tpr, label=f'Epoch {(ix + 1) * 10}')
plt.xlabel('False positive rate')
plt.ylabel('True positive rate')
plt.title('ROC curve of ' + name)
plt.legend(loc='best')
plt.savefig(path)
plt.show()
def plot_roc(roc, path, name):
plt.plot(roc, label='ROC AUC')
plt.legend(frameon=False)
plt.ylabel('ROC AUC')
plt.title('ROC AUC Score of ' + name)
plt.xlabel('Epoch')
plt.savefig(path)
plt.show()
def plot_loss(train_loss, test_loss, path, name):
plt.plot(train_loss, label='Training loss')
plt.plot(test_loss, label='Validation loss')
plt.legend(frameon=False)
plt.ylabel('Loss')
plt.xlabel('Epoch')
plt.title(f'Loss of ' + name)
plt.savefig(path)
plt.show()
def plot_acc(train_acc, test_acc, path, name):
plt.plot(train_acc, label='Training Acc')
plt.plot(test_acc, label='Validation Acc')
plt.legend(frameon=False)
plt.ylabel('Percentage')
plt.xlabel('Epoch')
plt.title(f'Binary accuracy of ' + name)
plt.savefig(path)
plt.show()
def fill_labels(labels):
labels = labels.reshape((len(labels), 1))
for i in range(18):
z = np.zeros((len(labels), 1))
labels = np.append(labels, z, axis=1)
return labels