plot_partial_dependence
method plot_partial_dependence(models=None, columns=None, kind="average", pair=None, target=1, title=None, legend="lower right", figsize=(900, 600), 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. The plot can take two forms:
- If
pair
is None: Single feature partial dependence lines. The deciles of the feature values are shown with tick marks on the bottom. - If
pair
is defined: Two-way partial dependence plots are plotted as contour plots (only allowed for a single model).
Read more about partial dependence on sklearn's documentation. This plot is not available for multilabel nor multiclass-multioutput classification tasks.
Parameters | models: int, str, Model, slice, sequence or None, default=None
Models to plot. If None, all models are selected.
columns: int, str, slice, sequence or None, default=None
Features to get the partial dependence from. If None, it
uses the first 3 features in the dataset.
kind: str or sequence, default="average"
Kind of depedence to plot. Use a sequence or add pair: int, str or None, default=None+ between
options to select more than one. Choose from:
This parameter is ignored when plotting feature pairs.
Feature with which to pair the features selected by
target: int or str, default=1columns . If specified, the resulting figure displays
contour plots. Only allowed when plotting a single model.
If None, the plots show the partial dependece of single
features.
Class in the target column to look at (only for multiclass
classification tasks).
title: str, dict or None, default=None
Title for the plot.
legend: str, dict or None, default="lower right"
Legend for the plot. See the user guide for
an extended description of the choices.
figsize: tuple, default=(900, 600)
Figure's size in pixels, format as (x, y).
filename: str or None, default=None
Save the plot using this name. Use "auto" for automatic
naming. The type of the file depends on the provided name
(.html, .png, .pdf, etc...). If display: bool or None, default=Truefilename has no file type,
the plot is saved as html. If None, the plot is not saved.
Whether to render the plot. If None, it returns the figure.
|
Returns | go.Figure or None
Plot object. Only returned if display=None .
|
See Also
Plot a model's feature importance.
Plot the partial correlation of shap values.
Plot the feature permutation importance of models.
Example
>>> from atom import ATOMClassifier
>>> from sklearn.datasets import load_breast_cancer
>>> X, y = load_breast_cancer(return_X_y=True, as_frame=True)
>>> atom = ATOMClassifier(X, y)
>>> atom.run(["LR", "RF"])
>>> atom.plot_partial_dependence(kind="average+individual", legend="upper left")
>>> atom.rf.plot_partial_dependence(columns=(3, 4), pair=2)