FeatureImportanceCoefficientsDisplay#
- class skore.FeatureImportanceCoefficientsDisplay(report_type, coefficients)[source]#
Feature importance display.
Each report type produces its own output frame and plot.
- Parameters:
- report_type{“estimator”, “cross-validation”, “comparison-estimator”, “comparison-cross-validation”}
Report type from which the display is created.
- coefficientsDataFrame | list[DataFrame]
The coefficients data to display.
- Attributes:
- ax_matplotlib Axes
Axes with the different matplotlib axis.
- figure_matplotlib Figure
Figure containing the plot.
Examples
>>> from sklearn.datasets import load_diabetes >>> from sklearn.linear_model import LinearRegression >>> from skore import train_test_split >>> from skore import EstimatorReport >>> X, y = load_diabetes(return_X_y=True) >>> split_data = train_test_split( >>> X=X, y=y, random_state=0, as_dict=True, shuffle=False >>> ) >>> report = EstimatorReport(LinearRegression(), **split_data) >>> display = report.feature_importance.coefficients() >>> display.plot() >>> display.frame() Coefficient Intercept 151.487952 Feature #0 -11.861904 Feature #1 -238.445509 Feature #2 505.395493 Feature #3 298.977119 ... ...
- frame()[source]#
Return coefficients as a DataFrame.
- Returns:
- pd.DataFrame
The structure of the returned frame depends on the underlying report type:
If an
EstimatorReport, a single column “Coefficient”, with the index being the feature names.If a
CrossValidationReport, the columns are the feature names, and the index is the respective split number.If a
ComparisonReport, the columns are the models passed in the report, with the index being the feature names.
- plot(**kwargs)[source]#
Plot the coefficients of linear models.
- Parameters:
- **kwargsdict
Additional keyword arguments to be passed to the plot method.
- set_style(*, policy='override', **kwargs)[source]#
Set the style parameters for the display.
- Parameters:
- policyLiteral[“override”, “update”], default=”override”
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.
- **kwargsdict
Style parameters to set. Each parameter name should correspond to a a style attribute passed to the plot method of the display.
- 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.