forked from StanfordAI4HI/RepBM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze_hiv.py
More file actions
74 lines (67 loc) · 2.62 KB
/
Copy pathanalyze_hiv.py
File metadata and controls
74 lines (67 loc) · 2.62 KB
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
"""
Loads saved HIV results and displays a comparison between the resutls of the
representation balancing MDP and a vanilla MDP
"""
import numpy as np
import matplotlib.pyplot as plt
import os
base_fname = "results/data_hiv"
fname = base_fname + ".npz"
idx_file = 1
while os.path.isfile(fname):
loaded_data = np.load(fname)
if idx_file == 1:
estm_list = list(loaded_data["estm_list"])
estm_bsl_list = list(loaded_data["estm_bsl_list"])
ips_list = list(loaded_data["ips_list"])
pdis_list = list(loaded_data["pdis_list"])
wpdis_list = list(loaded_data["wpdis_list"])
else:
estm_list += list(loaded_data["estm_list"])
estm_bsl_list += list(loaded_data["estm_bsl_list"])
ips_list += list(loaded_data["ips_list"])
pdis_list += list(loaded_data["pdis_list"])
wpdis_list += list(loaded_data["wpdis_list"])
idx_file += 1
fname = base_fname + str(idx_file) + ".npz"
true_value = 5.9*10**9
print('estm err : ',
np.mean((np.array(estm_list) - true_value) ** 2)**0.5 /
true_value)
print('estm err ste : ',
np.std((np.array(estm_list) - true_value) ** 2)**0.5
/ len(estm_list)**0.5 / true_value)
print('estm_bsl err : ',
np.mean((np.array(estm_bsl_list) - true_value) ** 2)**0.5 /
true_value)
print('estm_bsl err ste : ',
np.std((np.array(estm_bsl_list) - true_value) ** 2)**0.5
/ len(estm_list)**0.5 / true_value)
print('ips err : ',
np.mean((np.array(ips_list) - true_value) ** 2)**0.5 /
true_value)
print('ips err ste : ',
np.std((np.array(ips_list) - true_value) ** 2)**0.5
/ len(estm_list)**0.5 / true_value)
print('pdis err : ',
np.mean((np.array(pdis_list) - true_value) ** 2)**0.5 /
true_value)
print('pdis err ste : ',
np.std((np.array(pdis_list) - true_value) ** 2)**0.5
/ len(estm_list)**0.5 / true_value)
print('wpdis err : ',
np.mean((np.array(wpdis_list) - true_value) ** 2)**0.5 /
true_value)
print('wpdis err ste : ',
np.std((np.array(wpdis_list) - true_value) ** 2)**0.5
/ len(estm_list)**0.5 / true_value)
normalize = True
bins_num = 'auto'
est_us_hy, est_us_hx = np.histogram(estm_list, bins_num, normed=normalize)
est_bsl_hy, est_bsl_hx = np.histogram(estm_bsl_list, bins_num, normed=normalize)
plt.plot((est_us_hx[:-1]+est_us_hx[1:])/2, est_us_hy, label = "our model")
plt.plot((est_bsl_hx[:-1]+est_bsl_hx[1:])/2, est_bsl_hy, label = "baseline model")
plt.plot([true_value, true_value], [0, max(est_us_hy)], label = "\"true\" value")
plt.xlabel("value estimate")
plt.legend()
plt.savefig('results/hiv_figures/tempfig_1.png')