PermutationImportanceDisplay#
- class skore.PermutationImportanceDisplay(*, importances, report_type)[source]#
Display to inspect feature importance via feature permutation.
- Parameters:
- importancespd.DataFrame
The importances computed after permuting the input features. The columns are:
estimatordata_sourcemetricfeaturelabeloroutput(classification vs. regression)repetitionvalue
- report_type{“estimator”}
Report type from which the display is created.
- Attributes:
- facet_seaborn FacetGrid
FacetGrid containing the permutation importance.
- figure_matplotlib Figure
Figure containing the permutation importance.
- ax_matplotlib Axes
Axes with permutation importance.
- frame(*, metric=None, aggregate=('mean', 'std'))[source]#
Get the feature importance in a dataframe format.
- Parameters:
- metricstr or list of str, default=None
Filter the importances by metric. If
None, all importances associated with each metric are returned.- aggregate{“mean”, “std”}, (“mean”, std) or None, default=(“mean”, “std”)
Aggregate the importances by the given metric.
- Returns:
- pd.DataFrame
Dataframe containing the importances.
- plot(*, subplot_by='auto', metric=None)[source]#
Plot the permutation importance.
- Parameters:
- subplot_bystr, tuple of str or None, default=”auto”
Column(s) to use for subplotting. The possible values are:
if
"auto", depending of the information available, a meaningful decision is made to create subplots.if a string, the corresponding column of the dataframe is used to create several subplots. Those plots will be a organized in a grid of a single row and several columns.
if a tuple of strings, the corresponding columns of the dataframe are used to create several subplots. Those plots will be a organized in a grid of several rows and columns. The first element of the tuple is the row and the second element is the column.
if
None, all information is plotted on a single plot. An error is raised if there is too much information to plot on a single plot.
- metricstr or list of str, default=None
Filter the importances by metric. If
None, all importances associated with each metric are plotted.
- set_style(*, policy='update', boxplot_kwargs=None, stripplot_kwargs=None)[source]#
Set the style parameters for the display.
- Parameters:
- policy{“override”, “update”}, default=”update”
Policy to use when setting the style parameters. If “override”, existing settings are set to the provided values. If “update”, existing settings are not changed; only settings that were previously unset are changed.
- boxplot_kwargsdict, default=None
Keyword arguments to be passed to
seaborn.boxplot()for rendering the importances with aEstimatorReport.- stripplot_kwargsdict, default=None
Keyword arguments to be passed to
seaborn.stripplot()for rendering the importances with aEstimatorReport.
- Returns:
- selfobject
Returns the instance itself.
- Raises:
- ValueError
If a style parameter is unknown.
- static style_plot(plot_func)[source]#
Apply consistent style to skore displays.
This decorator: 1. Applies default style settings 2. Executes
plot_func3. Callsplt.tight_layout()to make sure axis does not overlap 4. Restores the original style settings- Parameters:
- plot_funccallable
The plot function to be decorated.
- Returns:
- callable
The decorated plot function.