Skip to content

plot_partial_dependence


method plot_partial_dependence(models=None, columns=None, kind="average", target=None, title=None, figsize=(10, 6), filename=None, display=True) [source]

Plot the partial dependence of features. The partial dependence of a feature (or a set of features) corresponds to the response of the model for each possible value of the feature. Two-way partial dependence plots are plotted as contour plots (only allowed for single model plots). The deciles of the feature values will be shown with tick marks on the x-axes for one-way plots, and on both axes for two-way plots. Read more about partial dependence on sklearn's documentation.

Parameters:

models: str, sequence or None, optional (default=None)
Name of the models to plot. If None, all the models in the pipeline are selected.

columns: int, str, sequence or None, optional (default=None)
Features or feature pairs (name or index) to get the partial dependence from. Maximum of 3 allowed. If None, it uses the top 3 features if the feature_importance attribute is defined, else it uses the first 3 features in the dataset.

kind: str, optional (default="average")
  • "average": Plot the partial dependence averaged across all the samples in the dataset.
  • "individual": Plot the partial dependence per sample (Individual Conditional Expectation).
  • "both": Plot both the average (as a thick line) and the individual (thin lines) partial dependence.

This parameter is ignored when plotting feature pairs.

target: int or str, optional (default=1)
Index or name of the class in the target column to look at. Only for multi-class classification tasks.

title: str or None, optional (default=None)
Plot's title. If None, the title is left empty.

figsize: tuple, optional (default=(10, 6))
Figure's size, format as (x, y).

filename: str or None, optional (default=None)
Name of the file. Use "auto" for automatic naming. If None, the figure is not saved.

display: bool or None, optional (default=True)
Whether to render the plot. If None, it returns the matplotlib figure.

Returns: matplotlib.figure.Figure
Plot object. Only returned if display=None.


Example

from atom import ATOMClassifier

atom = ATOMClassifier(X, y)
atom.feature_selection(strategy="pca", n_features=6)
atom.run(["Tree", "Bag"], metric="precision")
atom.plot_partial_dependence()
plot_partial_dependence_1


atom.tree.plot_partial_dependence(features=(4, (3, 4)))

plot_partial_dependence_2
Back to top