r"""Display a Partial Dependence Plot. Parameters ---------- est : estimator The scikit-learn estimator for calculating partial dependence. X : numpy array The data on which the estimator was trained. features : list of int Feature numbers of ``X``. f
(est, X, features, fnames, tag,
n_jobs=-1, verbosity=0, directory=None)
| 880 | # |
| 881 | |
| 882 | def plot_partial_dependence(est, X, features, fnames, tag, |
| 883 | n_jobs=-1, verbosity=0, directory=None): |
| 884 | r"""Display a Partial Dependence Plot. |
| 885 | |
| 886 | Parameters |
| 887 | ---------- |
| 888 | est : estimator |
| 889 | The scikit-learn estimator for calculating partial dependence. |
| 890 | X : numpy array |
| 891 | The data on which the estimator was trained. |
| 892 | features : list of int |
| 893 | Feature numbers of ``X``. |
| 894 | fnames : list of str |
| 895 | The feature names to plot. |
| 896 | tag : str |
| 897 | Unique identifier for the plot |
| 898 | n_jobs : int, optional |
| 899 | The maximum number of parallel jobs. |
| 900 | verbosity : int, optional |
| 901 | The amount of logging from 0 (minimum) and higher. |
| 902 | directory : str |
| 903 | Directory where the plot will be stored. |
| 904 | |
| 905 | Returns |
| 906 | ------- |
| 907 | None : None. |
| 908 | |
| 909 | References |
| 910 | ---------- |
| 911 | |
| 912 | http://scikit-learn.org/stable/auto_examples/ensemble/plot_partial_dependence.html#sphx-glr-auto-examples-ensemble-plot-partial-dependence-py |
| 913 | |
| 914 | """ |
| 915 | |
| 916 | logger.info("Generating Partial Dependence Plot") |
| 917 | |
| 918 | # Plot partial dependence |
| 919 | |
| 920 | fig, axs = plot_partial_dependence(est, X, features, feature_names=fnames, |
| 921 | grid_resolution=50, n_jobs=n_jobs, |
| 922 | verbose=verbosity) |
| 923 | title = "Partial Dependence Plot" |
| 924 | fig.suptitle(title) |
| 925 | plt.subplots_adjust(top=0.9) # tight_layout causes overlap with suptitle |
| 926 | |
| 927 | # Save the plot |
| 928 | write_plot(model, 'matplotlib', plt, 'partial_dependence', tag, directory) |
| 929 | |
| 930 | |
| 931 | # |
nothing calls this directly
no test coverage detected