Ejemplo n.º 1
0
                                 time,
                                 'training',
                                 'norm_aupdc',
                                 drop_opt,
                                 resample='')
display_feature_names = {f: to_readable_names([f])[0] for f in feature_names}
display_feature_names = _fix_long_names(display_feature_names)
feature_units = {f: get_units(f) for f in feature_names}

unnormalize_func = None
myInterpreter = InterpretToolkit()
fnames = get_fnames(model_name, target, time, resample_method, drop_opt,
                    calibrate)
myInterpreter.load_results(fnames=fnames)

ice_fnames = get_ice_fnames(model_name, target, time, resample_method,
                            drop_opt, calibrate)
ice_dict = myInterpreter.load_results(fnames=ice_fnames)

fig, axes = myInterpreter.plot_ale(
    features=feature_names[:10],
    display_feature_names=display_feature_names,
    display_units=feature_units,
    title=f'{plt_config.title_dict[target]} {time.replace("_", " ").title()}',
    unnormalize=unnormalize_func,
    ice_curves=ice_dict,
)

fname = f'ale_{model_name}_{target}_{time}_{drop_opt}_{resample_method}{calibrate}.png'
base_plot.save_figure(fig=fig, fname=fname)
        if normalize_method != None:
            unnormalize_func = UnNormalize(model.steps[1][1], feature_names)
        else:
            unnormalize_func = None

        result_dict = myInterpreter.calc_ale(
            features=important_vars,
            nbootstrap=100,
            subsample=1.0,
            njobs=njobs,
            nbins=30,
        )
        ale_results.append(result_dict)

    myInterpreter.model_names = model_set

    ale_results = merge_nested_dict(ale_results)
    myInterpreter.set_results(ale_results, option='ale')
    fig, axes = myInterpreter.plot_ale(
        display_feature_names=display_feature_names,
        to_probability=True,
        display_units=feature_units,
        title=
        f'{plt_config.title_dict[target]} {time.replace("_", " ").title()}',
        unnormalize=unnormalize_func,
        n_columns=n_columns,
        figsize=figsize)

    fname = f'ale_{target}_{time}_{drop_opt}_special.png'
    base_plot.save_figure(fig=fig, fname=fname)
Ejemplo n.º 3
0
ds.close()

display_feature_names = {f: to_readable_names([f])[0] for f in features}
display_feature_names = _fix_long_names(display_feature_names)
###feature_units = {f: get_units(f)for f in features}

myInterpreter = InterpretToolkit()
fnames = [get_fnames(m, target, time, drop_opt) for m in model_names]

results = myInterpreter.load_results(fnames=fnames)
feature_names = results[
    'ale_variance_interactions_rankings__LogisticRegression'].values

feature_names = feature_names[:3]
fnames = [get_2d_ale(m, target, time, drop_opt) for m in model_names]
ale_data = myInterpreter.load_results(fnames=fnames)

feature_names = [tuple(f.split('__')) for f in feature_names]

print(feature_names)

fig, axes = myInterpreter.plot_ale(
    ale_data=ale_data,
    features=feature_names,
    display_feature_names=display_feature_names,
    title=f'{plt_config.title_dict[target]} {time.replace("_", " ").title()}',
    hspace=1.0)

fname = f'ale_2D_{target}_{time}_{drop_opt}.png'
base_plot.save_figure(fig=fig, fname=fname)