1"""
2Created on 30 Oct 2018
3
4@author: jhkwakkel
5"""
6
7import matplotlib.pyplot as plt
8import numpy as np
9import pandas as pd
10import seaborn as sns
11
12from ema_workbench import ema_logging, load_results
13from ema_workbench.analysis.feature_scoring import get_ex_feature_scores, RuleInductionType
14
15ema_logging.log_to_stderr(level=ema_logging.INFO)
16
17# load data
18fn = r"./data/1000 flu cases no policy.tar.gz"
19x, outcomes = load_results(fn)
20
21x = x.drop(["model", "policy"], axis=1)
22y = np.max(outcomes["infected_fraction_R1"], axis=1)
23
24all_scores = []
25for i in range(100):
26 indices = np.random.choice(np.arange(0, x.shape[0]), size=x.shape[0])
27 selected_x = x.iloc[indices, :]
28 selected_y = y[indices]
29
30 scores = get_ex_feature_scores(selected_x, selected_y, mode=RuleInductionType.REGRESSION)[0]
31 all_scores.append(scores)
32all_scores = pd.concat(all_scores, axis=1, sort=False)
33
34sns.boxplot(data=all_scores.T)
35plt.show()