Skip to content

Commit c9d4677

Browse files
authored
fix(skore-hub-project): Make feature_importance.coefficients return a Display (#2010)
The PR #1948 (`skore==0.10.2`) introduces changes: - change the output of the estimator report's accessor `feature_importance.coefficients`, from dataframe to display object, - add the `feature_importance.coefficients` accessor to the cross-validation report.
1 parent 8207a41 commit c9d4677

File tree

11 files changed

+38
-23
lines changed

11 files changed

+38
-23
lines changed

ci/requirements/skore-hub-project/python-3.10/scikit-learn-1.4/test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ six==1.17.0
248248
# via python-dateutil
249249
skops==0.13.0
250250
# via skore-hub-project (skore-hub-project/pyproject.toml)
251-
skore==0.10.1
251+
skore==0.10.2
252252
# via skore-hub-project (skore-hub-project/pyproject.toml)
253253
skore-local-project==0.0.3
254254
# via skore

ci/requirements/skore-hub-project/python-3.10/scikit-learn-1.7/test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ six==1.17.0
248248
# via python-dateutil
249249
skops==0.13.0
250250
# via skore-hub-project (skore-hub-project/pyproject.toml)
251-
skore==0.10.1
251+
skore==0.10.2
252252
# via skore-hub-project (skore-hub-project/pyproject.toml)
253253
skore-local-project==0.0.3
254254
# via skore

ci/requirements/skore-hub-project/python-3.11/scikit-learn-1.4/test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ six==1.17.0
246246
# via python-dateutil
247247
skops==0.13.0
248248
# via skore-hub-project (skore-hub-project/pyproject.toml)
249-
skore==0.10.1
249+
skore==0.10.2
250250
# via skore-hub-project (skore-hub-project/pyproject.toml)
251251
skore-local-project==0.0.3
252252
# via skore

ci/requirements/skore-hub-project/python-3.11/scikit-learn-1.7/test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ six==1.17.0
246246
# via python-dateutil
247247
skops==0.13.0
248248
# via skore-hub-project (skore-hub-project/pyproject.toml)
249-
skore==0.10.1
249+
skore==0.10.2
250250
# via skore-hub-project (skore-hub-project/pyproject.toml)
251251
skore-local-project==0.0.3
252252
# via skore

ci/requirements/skore-hub-project/python-3.12/scikit-learn-1.4/test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ six==1.17.0
246246
# via python-dateutil
247247
skops==0.13.0
248248
# via skore-hub-project (skore-hub-project/pyproject.toml)
249-
skore==0.10.1
249+
skore==0.10.2
250250
# via skore-hub-project (skore-hub-project/pyproject.toml)
251251
skore-local-project==0.0.3
252252
# via skore

ci/requirements/skore-hub-project/python-3.12/scikit-learn-1.7/test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ six==1.17.0
246246
# via python-dateutil
247247
skops==0.13.0
248248
# via skore-hub-project (skore-hub-project/pyproject.toml)
249-
skore==0.10.1
249+
skore==0.10.2
250250
# via skore-hub-project (skore-hub-project/pyproject.toml)
251251
skore-local-project==0.0.3
252252
# via skore

ci/requirements/skore-hub-project/python-3.13/scikit-learn-1.5/test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ six==1.17.0
246246
# via python-dateutil
247247
skops==0.13.0
248248
# via skore-hub-project (skore-hub-project/pyproject.toml)
249-
skore==0.10.1
249+
skore==0.10.2
250250
# via skore-hub-project (skore-hub-project/pyproject.toml)
251251
skore-local-project==0.0.3
252252
# via skore

ci/requirements/skore-hub-project/python-3.13/scikit-learn-1.6/test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ six==1.17.0
246246
# via python-dateutil
247247
skops==0.13.0
248248
# via skore-hub-project (skore-hub-project/pyproject.toml)
249-
skore==0.10.1
249+
skore==0.10.2
250250
# via skore-hub-project (skore-hub-project/pyproject.toml)
251251
skore-local-project==0.0.3
252252
# via skore

ci/requirements/skore-hub-project/python-3.13/scikit-learn-1.7/test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ six==1.17.0
246246
# via python-dateutil
247247
skops==0.13.0
248248
# via skore-hub-project (skore-hub-project/pyproject.toml)
249-
skore==0.10.1
249+
skore==0.10.2
250250
# via skore-hub-project (skore-hub-project/pyproject.toml)
251251
skore-local-project==0.0.3
252252
# via skore

skore-hub-project/src/skore_hub_project/media/feature_importance.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
from inspect import signature
66
from typing import ClassVar, Literal, cast
77

8+
from pandas import DataFrame
89
from pydantic import Field, computed_field
9-
from skore import EstimatorReport
10+
from skore import CrossValidationReport, EstimatorReport
1011

1112
from .media import Media, Representation
1213

1314

1415
class FeatureImportance(Media): # noqa: D101
15-
report: EstimatorReport = Field(repr=False, exclude=True)
16+
report: EstimatorReport | CrossValidationReport = Field(repr=False, exclude=True)
1617
accessor: ClassVar[str]
1718
category: Literal["feature_importance"] = "feature_importance"
1819

@@ -32,15 +33,18 @@ def representation(self) -> Representation | None: # noqa: D102
3233
k: v for k, v in self.attributes.items() if k in function_parameters
3334
}
3435

35-
dataframe = function(**function_kwargs)
36+
result = function(**function_kwargs)
37+
38+
if not isinstance(result, DataFrame):
39+
result = result.frame()
40+
41+
serialized = result.fillna("NaN").to_dict(orient="tight")
3642

37-
return Representation(
38-
media_type="application/vnd.dataframe",
39-
value=dataframe.fillna("NaN").to_dict(orient="tight"),
40-
)
43+
return Representation(media_type="application/vnd.dataframe", value=serialized)
4144

4245

4346
class Permutation(FeatureImportance): # noqa: D101
47+
report: EstimatorReport = Field(repr=False, exclude=True)
4448
accessor: ClassVar[str] = "feature_importance.permutation"
4549
key: str = "permutation"
4650
verbose_name: str = "Feature importance - Permutation"
@@ -55,6 +59,7 @@ class PermutationTest(Permutation): # noqa: D101
5559

5660

5761
class MeanDecreaseImpurity(FeatureImportance): # noqa: D101
62+
report: EstimatorReport = Field(repr=False, exclude=True)
5863
accessor: ClassVar[str] = "feature_importance.mean_decrease_impurity"
5964
key: str = "mean_decrease_impurity"
6065
verbose_name: str = "Feature importance - Mean Decrease Impurity (MDI)"

0 commit comments

Comments
 (0)