sd_prim_PCA_flu.py

 1"""
 2
 3This file illustrated the use of the workbench for doing
 4a PRIM analysis with PCA preprocessing
 5
 6The data was generated using a system dynamics models implemented in Vensim.
 7See flu_example.py for the code.
 8
 9
10"""
11
12import matplotlib.pyplot as plt
13
14import ema_workbench.analysis.prim as prim
15from ema_workbench import ema_logging, load_results
16
17#
18# .. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>
19
20ema_logging.log_to_stderr(level=ema_logging.INFO)
21
22# load data
23fn = r"./data/1000 flu cases no policy.tar.gz"
24x, outcomes = load_results(fn)
25
26# specify y
27y = outcomes["deceased_population_region_1"][:, -1] > 1000000
28
29rotated_experiments, rotation_matrix = prim.pca_preprocess(x, y, exclude=["model", "policy"])
30
31# perform prim on modified results tuple
32prim_obj = prim.Prim(rotated_experiments, y, threshold=0.8)
33box = prim_obj.find_box()
34
35box.show_tradeoff()
36box.inspect(22)
37plt.show()