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=1,
            subsample=0.5,
            njobs=njobs,
            nbins=30,
        )

        print('computing ice curves...')
        ice_dict = myInterpreter.calc_ice(features=important_vars,
                                          njobs=njobs,
                                          nbins=30,
                                          subsample_size=200)

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

        fname = f'ale_{model_name}_{target}_{time}_{drop_opt}.png'
        base_plot.save_figure(fig=fig, fname=fname)
Example #2
0
    else:
        models = [model.steps[-1][1]]
        examples_transformed, target_values_transformed = just_transforms(
            model, examples, target_values)
        feature_names.remove('Run Date')

    myInterpreter = InterpretToolkit(models=models,
                                     model_names=model_names,
                                     examples=examples_transformed,
                                     targets=target_values_transformed,
                                     feature_names=feature_names)

    results = myInterpreter.calc_ice(
        features=feature_names,
        n_bootstrap=1,
        subsample=200,
        n_jobs=njobs,
        n_bins=35,
    )

    results_fname = join(
        ale_path,
        f'ice_results_{model_name}_{resample_method}_{target}_{time}{drop_opt}{calibrate}.nc'
    )

    print(f'Saving {results_fname}...')
    myInterpreter.save_results(fname=results_fname, data=results)

duration = datetime.datetime.now() - start_time
seconds = duration.total_seconds()
hours = seconds // 3600