Skip to content

plot_permutation_importance


method plot_permutation_importance(models=None, show=None, n_repeats=10, title=None, figsize=None, filename=None, display=True) [source]

Plot the feature permutation importance of models. Calculating permutations can be time-consuming, especially if n_repeats is high. For this reason, the permutations are stored under the permutations attribute. If the plot is called again for the same model with the same n_repeats, it will use the stored values, making the method considerably faster. The feature_importance attribute is updated with the extracted importance ranking.

Parameters:

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

show: int, optional (default=None)
Number of features (ordered by importance) to show. None to show all.

n_repeats: int, optional (default=10)
Number of times to permute each feature.

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

figsize: tuple or None, optional (default=None)
Figure's size, format as (x, y). If None, it adapts the size to the number of features shown.

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: fig: matplotlib.figure.Figure
Plot object. Only returned if display=None.


Example

from atom import ATOMClassifier

atom = ATOMClassifier(X, y)
atom.run(["LR", "LDA"], metric="average_precision")
atom.lda.plot_permutation_importance(show=10, n_repeats=7)
plot_permutation_importance
Back to top