-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscratch.py
132 lines (101 loc) · 4.22 KB
/
scratch.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import numpy as np
import matplotlib.pyplot as plt
# # single object data
# tasks = ["pick", "push", "move"]
# prior_grasping = np.array([0., 0., 0.]) + 0.1
# whirl_grasping = np.array([5./9., 3./9., 6./9.]) + 0.1
# ours_bo_grasping = np.array([0, 4./9., 5./9.]) + 0.1
# ours_grasping = np.array([1., 8./9., 1.]) + 0.1
# prior_task_success = np.array([0., 0., 0.]) + 0.1
# whirl_task_success = np.array([4./9., 0., 0.]) + 0.1
# ours_bo_task_success = np.array([0, 4./9., 4./9.]) + 0.1
# ours_task_success = np.array([1., 7./9., 7./9.]) + 0.1
# # multi object data
# tasks = ["Multi Object"]
# prior_grasping = np.array([0.]) + 0.1
# whirl_grasping = np.array([4./12.]) + 0.1
# ours_bo_grasping = np.array([5./12.]) + 0.1
# ours_grasping = np.array([1.]) + 0.1
# prior_task_success = np.array([0.]) + 0.1
# whirl_task_success = np.array([1./12.]) + 0.1
# ours_bo_task_success = np.array([4./12.]) + 0.1
# ours_task_success = np.array([11./12.]) + 0.1
# fig, ax = plt.subplots(1, 2)
# x = np.arange(len(tasks)) # the label locations
# width = 0.15 # the width of the bars
# multiplier = 0
# offset = width * multiplier
# rects = ax[0].bar(x + offset, prior_grasping, width, label="prior")
# # ax[0].bar_label(rects, padding=3)
# rects = ax[1].bar(x + offset, prior_task_success, width, label="prior")
# multiplier += 1
# offset = width * multiplier
# rects = ax[0].bar(x + offset, whirl_grasping, width, label="whirl")
# # ax.bar_label(rects, padding=3)
# rects = ax[1].bar(x + offset, whirl_task_success, width, label="whirl")
# multiplier += 1
# offset = width * multiplier
# rects = ax[0].bar(x + offset, ours_bo_grasping, width, label="ours-bo")
# # ax.bar_label(rects, padding=3)
# rects = ax[1].bar(x + offset, ours_bo_task_success, width, label="ours-bo")
# multiplier += 1
# offset = width * multiplier
# rects = ax[0].bar(x + offset, ours_grasping, width, label="ours")
# # ax.bar_label(rects, padding=3)
# rects = ax[1].bar(x + offset, ours_task_success, width, label="ours")
# # # Add some text for labels, title and custom x-axis tick labels, etc.
# ax[0].set_ylabel('Success Rate')
# ax[0].set_xticks(x + width * 3/2, tasks)
# ax[0].legend(loc='upper left')
# ax[0].set_ylim([0, 1.2])
# ax[1].set_xticks(x + width * 3/2, tasks)
# ax[1].set_ylim([0, 1.2])
# ax[0].set_title("Grasping Success")
# ax[1].set_title("Task Success")
# fig.suptitle('multi Object Tasks', fontsize=16)
# plt.show()
# data = dict()
# task = dict()
# task["without_residual"] = [29, 10, 15]
# task["with_residual"] = [15, 11, 17]
task_1_without_res = [29, 10, 15]
task_2_without_res = [18, 33, 19]
task_3_without_res = [15, 11, 11]
task_4_without_res = [20, 20, 26]
task_1_with_res = [15, 11, 17]
task_2_with_res = [12, 20, 17]
task_3_with_res = [11, 11, 5]
task_4_with_res = [27, 29, 29]
averages_with_res = [np.mean(task_1_with_res),
np.mean(task_2_with_res),
np.mean(task_3_with_res),
np.mean(task_4_with_res)]
yerr_with_res = [np.std(task_1_with_res)/np.sqrt(3),
np.std(task_2_with_res)/np.sqrt(3),
np.std(task_3_with_res)/np.sqrt(3),
np.std(task_4_with_res)/np.sqrt(3)]
averages_without_res = [np.mean(task_1_without_res),
np.mean(task_2_without_res),
np.mean(task_3_without_res),
np.mean(task_4_without_res)]
yerr_without_res = [np.std(task_1_without_res)/np.sqrt(3),
np.std(task_2_without_res)/np.sqrt(3),
np.std(task_3_without_res)/np.sqrt(3),
np.std(task_4_without_res)/np.sqrt(3)]
tasks = ["task_1", "task_2", "task_3", "task_4"]
x = np.arange(len(tasks)) # the label locations
width = 0.25 # the width of the bars
multiplier = 0
fig, ax = plt.subplots()
offset = width * multiplier
rects = ax.bar(x + offset, averages_without_res, width, label="without_residual", yerr=yerr_without_res)
ax.bar_label(rects, padding=3)
multiplier += 1
offset = width * multiplier
rects = ax.bar(x + offset, averages_with_res, width, label="with_residual", yerr=yerr_with_res)
ax.bar_label(rects, padding=3)
# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Rollouts')
ax.set_xticks(x + width, tasks)
ax.legend(loc='upper left')
plt.show()