forked from mtoneva/brain_language_nlp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_plots.py
49 lines (41 loc) · 1.37 KB
/
draw_plots.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
import matplotlib.pyplot as plt
import numpy as np
file1 = open('xl_net_results.txt', 'r')
Lines = file1.readlines()
xticks = [1,5,10,15,20,25,30,35]
fig, ax = plt.subplots()
plt.gca().set_prop_cycle(plt.cycler('color', plt.cm.rainbow(np.linspace(0, 1, 23))))
count = 0
# Strips the newline character
for line in Lines:
count +=1
if count % 2 == 0 and count!=2:
line = line.strip().strip('][').split(', ')
results = [float(i) for i in line]
print(results)
ax.set_xlabel('Sequence Length')
ax.set_ylabel('Accuracy')
ax.plot(xticks, results, label='layer' + str(int(count / 2)))
ax.legend()
ax.set_xlim(0, 45)
plt.title('XLNet prediction accuracy on fMRI data')
plt.show()
file1 = open('results.txt', 'r')
Lines = file1.readlines()
fig, ax = plt.subplots()
plt.gca().set_prop_cycle(plt.cycler('color', plt.cm.rainbow(np.linspace(0, 1, 12))))
count = 0
# Strips the newline character
for line in Lines:
count +=1
if count % 2 == 0 and count !=16:
line = line.strip().strip('][').split(', ')
results = [float(i) for i in line]
print(results)
ax.set_xlabel('Sequence Length')
ax.set_ylabel('Accuracy')
ax.plot(xticks, results, label= 'layer' + str(int(count/2)))
ax.legend()
ax.set_xlim(0, 45)
plt.title('BERT prediction accuracy on fMRI data')
plt.show()