ds = xr.open_dataset(fname)
features = [var for var in list(ds.data_vars) if 'matched' not in var
            ] + ['Run Date']

readable_feature_names = {
    feature: to_readable_names([feature])[0]
    for feature in features
}
feature_colors = {
    feature: to_readable_names([feature])[1]
    for feature in features
}

xticks = np.arange(0, 1.2, 0.2)

method_bool = True if method == 'multipass' else False
fig = myInterpreter.plot_importance(
    multipass=method_bool,
    display_feature_names=readable_feature_names,
    feature_colors=feature_colors,
    num_vars_to_plot=num_vars_to_plot,
    xticks=xticks,
    metric=metric.upper(),
    metrics_used=ylabels,
    ylabels=ylabels,
    xlabels=['NAUPDC'],
    n_columns=len(ml_models))

fname = f'{method}_permutation_importance_{time}_{mode}_{drop_opt}_compare.png'
base_plot.save_figure(fig=fig, fname=fname)
Beispiel #2
0
    feature: to_readable_names([feature])[1]
    for feature in features
}

adict = readable_feature_names
display_feature_names1 = {
    f'{f[0]}__{f[1]}': f'{adict[f[0]]} & {adict[f[1]]}'
    for f in list(itertools.combinations(features, r=2))
}

display_feature_names2 = {
    f'{f[1]}__{f[0]}': f'{adict[f[0]]} & {adict[f[1]]}'
    for f in list(itertools.combinations(features, r=2))
}

display_feature_names = {**display_feature_names1, **display_feature_names2}

fig = myInterpreter.plot_importance(
    data=results,
    method='perm_based_interactions',
    model_output='probability',
    display_feature_names=display_feature_names,
    num_vars_to_plot=num_vars_to_plot,
    ylabels=ylabels,
    figsize=figsize,
    plot_correlated_features=True,
    fontsize=5)

fname = f'perm_based_interact_rankings_{time}_{drop_opt}.png'
base_plot.save_figure(fig=fig, fname=fname)
Beispiel #3
0
for target in targets:
    fnames = [
        get_fnames(model_name, target, time, drop_opt)
        for model_name in ml_models
    ]
    results.append(myInterpreter.load_results(fnames))

readable_feature_names = {
    feature: to_readable_names([feature])[0]
    for feature in feature_names
}
feature_colors = {
    feature: to_readable_names([feature])[1]
    for feature in feature_names
}

fig = myInterpreter.plot_importance(
    data=results,
    method='ale_variance',
    model_output='probability',
    display_feature_names=readable_feature_names,
    feature_colors=feature_colors,
    num_vars_to_plot=num_vars_to_plot,
    ylabels=ylabels,
    figsize=figsize,
    plot_correlated_features=True,
)

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