Skip to content

Commit 70ced23

Browse files
committed
Merge branch 'main' into followup_1759
2 parents f522669 + e83d1c4 commit 70ced23

File tree

12 files changed

+375
-72
lines changed

12 files changed

+375
-72
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
version: 2
22
updates:
3-
43
- package-ecosystem: "github-actions"
54
directory: "/"
65
schedule:
76
interval: "monthly"
7+
cooldown:
8+
default-days: 14
89
commit-message:
910
prefix: "chore(dependencies): GITHUB-ACTIONS"
10-
1111
- package-ecosystem: "pip"
1212
directory: "/"
1313
schedule:
1414
interval: "weekly"
15+
cooldown:
16+
default-days: 14
17+
semver-patch-days: 7
1518
commit-message:
1619
prefix: "chore(dependencies): PIP"
1720
groups:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Permutation(FeatureImportance[EstimatorReport], ABC): # noqa: D101
4545
name: Literal["permutation"] = "permutation"
4646

4747
def content_to_upload(self) -> bytes | None: # noqa: D102
48-
for key, obj in reversed(self.report._cache.items()):
48+
for key, obj in reversed(list(self.report._cache.items())):
4949
if len(key) < 7:
5050
continue
5151

skore-hub-project/tests/conftest.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from datetime import datetime, timezone
2+
from functools import partial
3+
from importlib import reload
24
from unittest.mock import Mock
35
from urllib.parse import urljoin
46

@@ -141,11 +143,10 @@ def monkeypatch_tmpdir(monkeypatch, tmp_path):
141143
142144
https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir
143145
"""
144-
import importlib
145146
import tempfile
146147

147148
monkeypatch.setenv("TMPDIR", str(tmp_path))
148-
importlib.reload(tempfile)
149+
reload(tempfile)
149150

150151

151152
@fixture
@@ -155,7 +156,10 @@ def monkeypatch_skrub(monkeypatch):
155156
156157
https://github.com/skrub-data/skrub/blob/35f573ce586fe61ef2c72f4c0c4b188ebf2e664b/skrub/_reporting/_html.py#L153
157158
"""
159+
from skrub._dataframe import sample
160+
158161
monkeypatch.setattr("secrets.token_hex", lambda: "<token>")
162+
monkeypatch.setattr("skrub._dataframe.sample", partial(sample, seed=42))
159163

160164

161165
@fixture
@@ -210,11 +214,22 @@ def monkeypatch_sklearn_estimator_html_repr(monkeypatch):
210214
monkeypatch.setattr(importpath, lambda self: "<id>")
211215

212216

217+
@fixture
218+
def monkeypatch_rich(monkeypatch):
219+
"""Make `rich` silent."""
220+
from rich.console import Console
221+
222+
monkeypatch.setattr("rich.console.Console", partial(Console, quiet=True))
223+
monkeypatch.setattr("skore.console.quiet", True)
224+
monkeypatch.setattr("skore_hub_project.console.quiet", True)
225+
226+
213227
@fixture(autouse=True)
214228
def setup(
215229
monkeypatch_tmpdir,
216230
monkeypatch_matplotlib,
217231
monkeypatch_skrub,
218232
monkeypatch_skore_hub_envars,
219233
monkeypatch_sklearn_estimator_html_repr,
234+
monkeypatch_rich,
220235
): ...

skore/src/skore/_sklearn/_comparison/metrics_accessor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ def summarize(
6767
6868
Parameters
6969
----------
70-
data_source : {"test", "train", "X_y"}, default="test"
70+
data_source : {"test", "train", "X_y", "both"}, default="test"
7171
The data source to use.
7272
7373
- "test" : use the test set provided when creating the report.
7474
- "train" : use the train set provided when creating the report.
7575
- "X_y" : use the provided `X` and `y` to compute the metric.
76+
- "both" : use both the train and test sets to compute the metrics and
77+
present them side-by-side.
7678
7779
X : array-like of shape (n_samples, n_features), default=None
7880
New data on which to compute the metric. By default, we use the validation
@@ -254,6 +256,7 @@ def _compute_metric_scores(
254256
indicator_favorability=metric_kwargs.get(
255257
"indicator_favorability", False
256258
),
259+
data_source=data_source,
257260
)
258261
else: # "CrossValidationReport"
259262
results = _combine_cross_validation_results(

skore/src/skore/_sklearn/_comparison/utils.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import copy
2+
from typing import Literal
23

34
import pandas as pd
45

5-
from skore._sklearn.types import Aggregate
6+
from skore._sklearn.types import Aggregate, DataSource
67

78

89
def _combine_estimator_results(
910
individual_results: list[pd.DataFrame],
1011
estimator_names: list[str],
1112
indicator_favorability: bool,
13+
data_source: DataSource | Literal["both"],
1214
) -> pd.DataFrame:
1315
"""Combine a list of dataframes provided by `EstimatorReport`s.
1416
@@ -24,6 +26,9 @@ def _combine_estimator_results(
2426
indicator_favorability : bool
2527
Whether to keep the Favorability column.
2628
29+
data_source : {"test", "train", "X_y", "both"}
30+
The data source.
31+
2732
Examples
2833
--------
2934
>>> from skore._sklearn._comparison.utils import _combine_estimator_results
@@ -55,6 +60,7 @@ def _combine_estimator_results(
5560
... individual_results,
5661
... estimator_names,
5762
... indicator_favorability=False,
63+
... data_source="test",
5864
... )
5965
Estimator LogisticRegression_1 LogisticRegression_2
6066
Metric
@@ -73,7 +79,17 @@ def _combine_estimator_results(
7379
else:
7480
favorability = None
7581

76-
results.columns = pd.Index(estimator_names, name="Estimator")
82+
if data_source == "both":
83+
results.columns = pd.Index(
84+
[
85+
x
86+
for name in estimator_names
87+
for x in [f"{name} (train)", f"{name} (test)"]
88+
],
89+
name="Estimator",
90+
)
91+
else:
92+
results.columns = pd.Index(estimator_names, name="Estimator")
7793

7894
if favorability is not None:
7995
results["Favorability"] = favorability

skore/src/skore/_sklearn/_estimator/metrics_accessor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ class is set to the one provided when creating the report. If `None`,
19761976
def prediction_error(
19771977
self,
19781978
*,
1979-
data_source: DataSource = "test",
1979+
data_source: DataSource | Literal["both"] = "test",
19801980
X: ArrayLike | None = None,
19811981
y: ArrayLike | None = None,
19821982
subsample: float | int | None = 1_000,
@@ -1988,12 +1988,14 @@ def prediction_error(
19881988
19891989
Parameters
19901990
----------
1991-
data_source : {"test", "train", "X_y"}, default="test"
1991+
data_source : {"test", "train", "X_y", "both"}, default="test"
19921992
The data source to use.
19931993
19941994
- "test" : use the test set provided when creating the report.
19951995
- "train" : use the train set provided when creating the report.
19961996
- "X_y" : use the provided `X` and `y` to compute the metric.
1997+
- "both" : use both the train and test sets to compute the metrics and
1998+
present them side-by-side.
19971999
19982000
X : array-like of shape (n_samples, n_features), default=None
19992001
New data on which to compute the metric. By default, we use the validation

0 commit comments

Comments
 (0)