-
Notifications
You must be signed in to change notification settings - Fork 90
/
sd_prim_flu.py
56 lines (38 loc) · 1.32 KB
/
sd_prim_flu.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
"""
This file illustrated the use of the workbench for doing
a PRIM analysis.
The data was generated using a system dynamics models implemented in Vensim.
See flu_example.py for the code.
.. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>
chamarat <c.hamarat (at) tudelft (dot) nl>
"""
import matplotlib.pyplot as plt
import ema_workbench.analysis.prim as prim
from ema_workbench import ema_logging, load_results
ema_logging.log_to_stderr(level=ema_logging.INFO)
def classify(data):
# get the output for deceased population
ooi = data["deceased population region 1"]
return ooi[:, -1] > 1000000
# load data
fn = r"./data/1000 flu cases no policy.tar.gz"
results = load_results(fn)
# perform prim on modified results tuple
prim_obj = prim.setup_prim(results, classify, threshold=0.8, threshold_type=1)
box_1 = prim_obj.find_box()
box_1.show_ppt()
box_1.show_tradeoff()
# box_1.inspect([5, 6], style="graph", boxlim_formatter="{: .2f}")
fig, axes = plt.subplots(nrows=2, ncols=1)
box_1.inspect([5, 6], style="graph", boxlim_formatter="{: .2f}", ax=axes)
plt.show()
box_1.inspect(5)
box_1.select(5)
box_1.write_ppt_to_stdout()
box_1.show_pairs_scatter(5)
# print prim to std_out
print(prim_obj.stats_to_dataframe())
print(prim_obj.boxes_to_dataframe())
# visualize
prim_obj.show_boxes()
plt.show()