def load_flu_data(): path = os.path.dirname(__file__) fn = './data/1000 flu cases no policy.tar.gz' fn = os.path.join(path, fn) experiments, outcomes = load_results(fn) return experiments, outcomes
def load_eng_trans_data(): path = os.path.dirname(__file__) fn = './data/eng_trans.tar.gz' fn = os.path.join(path, fn) experiments, outcomes = load_results(fn) return experiments, outcomes
def load_scarcity_data(): path = os.path.dirname(__file__) fn = './data/1000 runs scarcity.tar.gz' fn = os.path.join(path, fn) experiments, outcomes = load_results(fn) return experiments, outcomes
def classify(data): #get the output for deceased population result = data['deceased population region 1'] #make an empty array of length equal to number of cases classes = np.zeros(result.shape[0]) #if deceased population is higher then 1.000.000 people, classify as 1 classes[result[:, -1] > 1000000] = 1 return classes #load data fn = r'./data/1000 flu cases.tar.gz' results = load_results(fn) experiments, results = results #extract results for 1 policy logical = experiments['policy'] == 'no policy' new_experiments = experiments[ logical ] new_results = {} for key, value in results.items(): new_results[key] = value[logical] results = (new_experiments, new_results) #perform prim on modified results tuple prim_obj = prim.setup_prim(results, classify, threshold=0.8, threshold_type=1)
''' Created on Jul 8, 2014 @author: [email protected] ''' import matplotlib.pyplot as plt from ema_workbench.util import ema_logging, load_results from ema_workbench.analysis.plotting import envelopes from ema_workbench.analysis.plotting_util import KDE ema_logging.log_to_stderr(ema_logging.INFO) file_name = r'./data/1000 flu cases.tar.gz' results = load_results(file_name) # the plotting functions return the figure and a dict of axes fig, axes = envelopes(results, group_by='policy', density=KDE, fill=True) # we can access each of the axes and make changes for key, value in axes.iteritems(): # the key is the name of the outcome for the normal plot # and the name plus '_density' for the endstate distribution if key.endswith('_density'): value.set_xscale('log') plt.show()
import sys sys.path sys.path.append('/home/philipp/Dropbox/Workspace_Zika_Models_Philipp/src') del sys from ema_workbench.util import merge_results, load_results, save_results filename = 'EMA108_vFinal_FullRUNLaptop' results2 = load_results(r'simulation_results/' + filename + '.tar.gz') filename = 'EMA324_vFinal_FullRUN_12core' results1 = load_results(r'simulation_results/' + filename + '.tar.gz') merged = merge_results(results1, results2, downsample=None) print('merge_1_successful') results2, results1 = None, None filename = 'EMA108_vFinal_FullRUN_hometv' results3 = load_results(r'simulation_results/' + filename + '.tar.gz') merged = merge_results(merged, results3, downsample=None) print('merge_1_successful') experiments, outcomes = merged import pandas as pd for key, value in outcomes.iteritems(): outcomes[key] = pd.DataFrame.from_dict(value) experiments = pd.DataFrame.from_dict(experiments) experiments.dropna(axis=0, inplace=True) for key, value in outcomes.iteritems():
Created on 20 sep. 2011 .. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl> ''' import numpy as np import matplotlib.pyplot as plt from ema_workbench.analysis.pairs_plotting import (pairs_lines, pairs_scatter, pairs_density) from ema_workbench.util import load_results, ema_logging ema_logging.log_to_stderr(level=ema_logging.DEFAULT_LEVEL) # load the data fh = r'.\data\1000 flu cases no policy.tar.gz' experiments, outcomes = load_results(fh) # transform the results to the required format # that is, we want to know the max peak and the casualties at the end of the # run tr = {} # get time and remove it from the dict time = outcomes.pop('TIME') for key, value in outcomes.items(): if key == 'deceased population region 1': tr[key] = value[:,-1] #we want the end value else: # we want the maximum value of the peak max_peak = np.max(value, axis=1)
Created on Sep 8, 2011 .. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl> gonengyucel ''' import matplotlib.pyplot as plt from ema_workbench.analysis.clusterer import cluster from ema_workbench.util import ema_logging, load_results ema_logging.log_to_stderr(ema_logging.INFO) #load the data data = load_results(r'..\examples\100 flu cases no policy.cPickle') # specify the number of desired clusters # note: the meaning of cValue is tied to the value for cMethod cValue = 5 #perform cluster analysis dist, clusteraloc, runlog, z = cluster(data=data, outcome='deceased population region 1', distance='gonenc', interClusterDistance='complete', cMethod = 'maxclust', cValue = cValue, plotDendrogram=False, plotClusters=False, groupPlot=False,