Skip to content

Commit 843b833

Browse files
An improvement to SkrubLearner.report() method (skrub-data#1815)
Co-authored-by: Jérôme Dockès <jerome@dockes.org>
1 parent c0995dd commit 843b833

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

skrub/_data_ops/_estimator.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,41 @@ def report(self, *, environment, mode, **full_report_kwargs):
144144
dict
145145
The result of ``DataOp.skb.full_report``: a dict containing
146146
``'result'``, ``'error'`` and ``'report_path'``.
147+
148+
Examples
149+
--------
150+
We start by creating the learner for a simple DataOp:
151+
152+
>>> import skrub
153+
>>> from sklearn.linear_model import LogisticRegression
154+
>>> from sklearn.datasets import make_classification
155+
>>> pred = skrub.X().skb.apply(LogisticRegression(), y=skrub.y())
156+
>>> X, y = make_classification(n_samples=20, random_state=0)
157+
>>> split = pred.skb.train_test_split({'X': X, 'y': y}, shuffle=False)
158+
>>> learner = pred.skb.make_learner()
159+
160+
We can now obtain reports for the different methods of the learner such
161+
as 'fit', 'predict_proba', etc.
162+
163+
>>> fit_results = learner.report(
164+
... environment=split["train"], mode="fit", open=False
165+
... ) # doctest: +SKIP
166+
>>> fit_results['report_path'] # doctest: +SKIP
167+
PosixPath('.../skrub_data/execution_reports/full_data_op_report_.../index.html')
168+
169+
Note that our learner has been fitted now, we can use it for predictions.
170+
171+
>>> predict_results = learner.report(
172+
... environment=split["train"], mode="predict", open=False
173+
... ) # doctest: +SKIP
174+
>>> predict_results['report_path'] # doctest: +SKIP
175+
PosixPath('.../skrub_data/execution_reports/full_data_op_report_.../index.html')
176+
177+
In addition to the report, we can also retrieve the actual output of
178+
the 'predict' method:
179+
180+
>>> predict_results['result'] # doctest: +SKIP
181+
array([0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0])
147182
"""
148183
from ._inspection import full_report
149184

0 commit comments

Comments
 (0)