forked from Guiliang/uTree_mimic_mountain_car
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_tree_result.py
57 lines (47 loc) · 1.93 KB
/
plot_tree_result.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
56
57
import math
import matplotlib.pyplot as plt
def read_result_csv(csv_dir):
home_linear_correl = []
home_oracle_correl = []
home_merge_correl = []
away_linear_correl = []
away_oracle_correl = []
away_merge_correl = []
end_linear_correl = []
end_oracle_correl = []
end_merge_correl = []
read_counter = 0
with open(csv_dir, 'rb') as file:
rows = file.readlines()
for row in rows:
if row == '\n':
continue
else:
# print row
row = row.replace('{', '').replace('}', '').replace('\n', '')
correlations = row.split(',')
read_counter += 1
if read_counter % 3 == 1:
home_linear_correl.append(float(correlations[0].strip().split(':')[1]))
elif read_counter % 3 == 2:
home_oracle_correl.append(float(correlations[0].strip().split(':')[1]))
elif read_counter % 3 == 0:
home_merge_correl.append(float(correlations[0].strip().split(':')[1]))
return home_linear_correl, home_oracle_correl, home_merge_correl
def plot_tree_correlation(home_correl):
length = len(home_correl)
game_numbers = range(1, length + 1, 1)
# game_numbers = [math.log(game_number,2)for game_number in game_numbers]
plt.plot(game_numbers, home_correl, label='correlation')
# plt.plot(game_numbers, away_correl, label='correlation away')
# plt.plot(game_numbers, end_correl)
plt.xlabel('game_numbers')
plt.ylabel('correlated coefficient')
plt.legend(loc = 'best')
plt.show()
if __name__ == "__main__":
home_linear_correl, home_oracle_correl, home_merge_correl = read_result_csv(
csv_dir='./bak-result-correlation-all-linear-epoch-decay-lr-st0-900')
plot_tree_correlation(home_linear_correl)
plot_tree_correlation(home_oracle_correl)
plot_tree_correlation(home_merge_correl)