def postprocess(self, pimp, output_dir):
    result = OrderedDict()

    def parse_pairwise(p):
        "parse pimp's way of having pairwise parameters as key as str and return list of individuals"
        res = [tmp.strip("' ") for tmp in p.strip('[]').split(',')]
        return res
    parameter_imp = {k: (v * 100) for (k, v) in pimp.evaluator.evaluated_parameter_importance.items()}
    param_imp_std = {}
    if hasattr(pimp.evaluator, 'evaluated_parameter_importance_uncertainty'):
        param_imp_std = {k: (v * 100) for (k, v) in pimp.evaluator.evaluated_parameter_importance_uncertainty.items()}
    for k in parameter_imp.keys():
        self.logger.debug('fanova-importance for %s: mean (over trees): %f, std: %s', k, parameter_imp[k], (str(param_imp_std[k]) if param_imp_std else 'N/A'))
    single_imp = {k: v for (k, v) in parameter_imp.items() if ((not k.startswith('[')) and (v > self.marginal_threshold))}
    pairwise_imp = {k: v for (k, v) in parameter_imp.items() if (k.startswith('[') and (v > self.marginal_threshold))}
    self.fanova_single_importance = single_imp
    self.fanova_pairwise_importance = single_imp
    single_imp = OrderedDict(sorted(single_imp.items(), key=operator.itemgetter(1), reverse=True))
    pairwise_imp = OrderedDict(sorted(pairwise_imp.items(), key=operator.itemgetter(1), reverse=True))
    table = []
    if (len(single_imp) > 0):
        table.extend([((((20 * '-') + ' Single importance: ') + (20 * '-')), (20 * '-'))])
        for (k, v) in single_imp.items():
            value = str(round(v, 4))
            if param_imp_std:
                value += (' +/- ' + str(round(param_imp_std[k], 4)))
            table.append((k, value))
    if (len(pairwise_imp) > 0):
        table.extend([((((20 * '-') + ' Pairwise importance: ') + (20 * '-')), (20 * '-'))])
        for (k, v) in pairwise_imp.items():
            name = ' & '.join(parse_pairwise(k))
            value = str(round(v, 4))
            if param_imp_std:
                value += (' +/- ' + str(round(param_imp_std[k], 4)))
            table.append((name, value))
    (keys, fanova_table) = ([k[0] for k in table], [k[1:] for k in table])
    df = DataFrame(data=fanova_table, index=keys)
    result['Importance'] = {'table': df.to_html(escape=False, header=False, index=True, justify='left')}
    result['Marginals'] = {p: {'figure': os.path.join(output_dir, 'fanova', (p + '.png'))} for p in single_imp.keys()}
    pairwise_plots = {' & '.join(parse_pairwise(p)): os.path.join(output_dir, 'fanova', ('_'.join(parse_pairwise(p)) + '.png')) for p in pairwise_imp.keys()}
    result['Pairwise Marginals'] = {p: {'figure': path} for (p, path) in pairwise_plots.items() if os.path.exists(path)}
    return result
def postprocess(self, pimp, output_dir):
    result = OrderedDict()

    def parse_pairwise(p):
        "parse pimp's way of having pairwise parameters as key as str and return list of individuals"
        res = [tmp.strip("' ") for tmp in p.strip('[]').split(',')]
        return res
    parameter_imp = {k: (v * 100) for (k, v) in pimp.evaluator.evaluated_parameter_importance.items()}
    param_imp_std = {}
    if hasattr(pimp.evaluator, 'evaluated_parameter_importance_uncertainty'):
        param_imp_std = {k: (v * 100) for (k, v) in pimp.evaluator.evaluated_parameter_importance_uncertainty.items()}
    for k in parameter_imp.keys():
        self.logger.debug('fanova-importance for %s: mean (over trees): %f, std: %s', k, parameter_imp[k], (str(param_imp_std[k]) if param_imp_std else 'N/A'))
    single_imp = {k: v for (k, v) in parameter_imp.items() if ((not k.startswith('[')) and (v > self.marginal_threshold))}
    pairwise_imp = {k: v for (k, v) in parameter_imp.items() if (k.startswith('[') and (v > self.marginal_threshold))}
    self.fanova_single_importance = single_imp
    self.fanova_pairwise_importance = single_imp
    single_imp = OrderedDict(sorted(single_imp.items(), key=operator.itemgetter(1), reverse=True))
    pairwise_imp = OrderedDict(sorted(pairwise_imp.items(), key=operator.itemgetter(1), reverse=True))
    table = []
    if (len(single_imp) > 0):
        table.extend([((((20 * '-') + ' Single importance: ') + (20 * '-')), (20 * '-'))])
        for (k, v) in single_imp.items():
            value = str(round(v, 4))
            if param_imp_std:
                value += (' +/- ' + str(round(param_imp_std[k], 4)))
            table.append((k, value))
    if (len(pairwise_imp) > 0):
        table.extend([((((20 * '-') + ' Pairwise importance: ') + (20 * '-')), (20 * '-'))])
        for (k, v) in pairwise_imp.items():
            name = ' & '.join(parse_pairwise(k))
            value = str(round(v, 4))
            if param_imp_std:
                value += (' +/- ' + str(round(param_imp_std[k], 4)))
            table.append((name, value))
    (keys, fanova_table) = ([k[0] for k in table], [k[1:] for k in table])
    df = DataFrame(data=fanova_table, index=keys)
    result['Importance'] = {'table': df.to_html(escape=False, header=False, index=True, justify='left')}
    result['Marginals'] = {p: {'figure': os.path.join(output_dir, 'fanova', (p + '.png'))} for p in single_imp.keys()}
    pairwise_plots = {' & '.join(parse_pairwise(p)): os.path.join(output_dir, 'fanova', ('_'.join(parse_pairwise(p)) + '.png')) for p in pairwise_imp.keys()}
    result['Pairwise Marginals'] = {p: {'figure': path} for (p, path) in pairwise_plots.items() if os.path.exists(path)}
    return result