ComparisonReport.inspection.coefficients#
- ComparisonReport.inspection.coefficients()[source]#
Retrieve the coefficients for each report, including the intercepts.
If the compared reports are
EstimatorReportinstances, the coefficients from each report’s estimator are returned as a single-column DataFrame.If the compared reports are
CrossValidationReportinstances, the coefficients across all cross-validation splits are retained and the columns are prefixed with the corresponding estimator name to distinguish them.Comparison reports with the same features are put under one key and are plotted together. When some reports share the same features and others do not, those with the same features are plotted together.
- Returns:
CoefficientsDisplayThe feature importance display containing model coefficients and intercept.
Examples
>>> from sklearn.datasets import load_diabetes >>> from sklearn.linear_model import Ridge >>> from skore import train_test_split >>> from skore import ComparisonReport, EstimatorReport >>> X, y = load_diabetes(return_X_y=True) >>> split_data = train_test_split(X=X, y=y, shuffle=False, as_dict=True) >>> report_big_alpha = EstimatorReport(Ridge(alpha=1e3), **split_data) >>> report_small_alpha = EstimatorReport(Ridge(alpha=1e-3), **split_data) >>> report = ComparisonReport({ ... "report small alpha": report_small_alpha, ... "report big alpha": report_big_alpha, ... }) >>> display = report.inspection.coefficients() >>> display.frame() estimator report big alpha report small alpha feature Feature #0 0.2... -11.6... Feature #1 0.0... -238.2... Feature #2 0.6... 505.5... Feature #3 0.5... 298.4... Feature #4 0.2... -408.5... Feature #5 0.2... 164.0... Feature #6 -0.4... -55.1... Feature #7 0.5... 123.0... Feature #8 0.6... 633.8... Feature #9 0.4... 99.4... Intercept 151.0... 151.5... >>> display.plot() # shows plot