-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexperiment_1_show_errorresults.py
120 lines (104 loc) · 3.62 KB
/
experiment_1_show_errorresults.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
# next is to add accel and see the difference
# add stiffness too
import numpy as np
from scipy import signal, stats
from matplotlib import pyplot as plt
from all_functions import *
import pickle
from warnings import simplefilter
import matplotlib
simplefilter(action='ignore', category=FutureWarning)
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
experiment_ID="experiment_1B"
fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(9, 3))
N = 9
stiffness_values = ["0", "500", "1k", "2k", "4k", "7k", "10k", "15k", "20k"]
x = np.arange(N) # the x locations for the groups
positions_cyclical = 2*np.arange(N)-0.25
positions_p2p = 2*np.arange(N)+0.25
y_lim=[0, .95]
y_lim_p0=[.05, .75]
## cyclical
file_address = "./results/{}/errors_all_cyclical.npy".format(experiment_ID)
errors_all = np.load(file_address)
errors_all_mean=errors_all.mean(1)
errors_all_std = errors_all.std(1)
print("Errors_mean: ",errors_all_mean)
print("Errors_std: ",errors_all_std)
p0_0 = axes[0].boxplot(
errors_all.mean(0).reshape(1,-1,1,N).squeeze(),
positions=positions_cyclical,
notch=True,
patch_artist=True,
showfliers=False)
p0_1 = axes[1].boxplot(
errors_all[0,:,:,:].reshape(1,-1,1,N).squeeze(),
positions=positions_cyclical,
notch=True,
patch_artist=True,
showfliers=False)
p0_2 = axes[2].boxplot(
errors_all[1,:,:,:].reshape(1,-1,1,N).squeeze(),
positions=positions_cyclical,
notch=True,
patch_artist=True,
showfliers=False)
# p-value
[f_ow, p_val] = stats.f_oneway(errors_all.mean(0)[:,0,0],errors_all.mean(0)[:,0,3])
print("p-value: ", p_val)
## p2p
file_address = "./results/{}/errors_all_p2p.npy".format(experiment_ID)
errors_all = np.load(file_address)
errors_all_mean=errors_all.mean(1)
errors_all_std = errors_all.std(1)
print("errors_mean: ",errors_all_mean)
print("errors_std: ",errors_all_std)
p1_0 = axes[0].boxplot(
errors_all.mean(0).reshape(1,-1,1,N).squeeze(),
positions=positions_p2p,
notch=True,
patch_artist=True,
showfliers=False)
axes[0].set_title(r'Average across both joints',fontsize=10)
axes[0].set_ylim(y_lim_p0)
axes[0].set_xlabel('Stiffness (N/m)')
axes[0].set_xticklabels(stiffness_values, rotation=45, fontsize=8)
axes[0].set_ylabel('RMSE (rads)')
p1_1 = axes[1].boxplot(
errors_all[0,:,:,:].reshape(1,-1,1,N).squeeze(),
positions=positions_p2p,
notch=True,
patch_artist=True,
showfliers=False)
axes[1].set_title('Proximal joint ($q_0$)', fontsize=10)
axes[1].set_ylim(y_lim)
axes[1].set_yticklabels([])
axes[1].set_xlabel('Stiffness (N/m)')
axes[1].set_xticklabels(stiffness_values, rotation=45, fontsize=8)
p1_2 = axes[2].boxplot(
errors_all[1,:,:,:].reshape(1,-1,1,N).squeeze(),
positions=positions_p2p,
notch=True,
patch_artist=True,
showfliers=False)
axes[2].set_title('Distal joint ($q_1$)', fontsize=10)
axes[2].set_ylim(y_lim)
axes[2].set_yticklabels([])
axes[2].set_xlabel('Stiffness (N/m)')
axes[2].set_xticklabels(stiffness_values, rotation=45, fontsize=8)
# changing the box colors
for bplot in (p1_0, p1_1, p1_2):
for patch in bplot['boxes']:
patch.set_facecolor('lightskyblue')
axes[2].legend([p0_2["boxes"][0], p1_2["boxes"][0]], ['cyclical','point-to-point'], loc='upper right', fontsize='small')#bbox_to_anchor=(1.6, 1.02)
fig.subplots_adjust(left=.06, right=.95, bottom=.17)
fig.savefig('./results/{}/exp1_error_vs_stiffness.pdf'.format(experiment_ID))
fig.savefig('./results/figures/exp1_error_vs_stiffness.pdf'.format(experiment_ID))
fig.savefig('./results/figures/exp1_error_vs_stiffness.png'.format(experiment_ID))
# p-value
[f_ow, p_val] = stats.f_oneway(errors_all.mean(0)[:,0,0],errors_all.mean(0)[:,0,3])
print("p-value: ", p_val)
##
plt.show()
#import pdb; pdb.set_trace()