Skip to content

Commit 192027f

Browse files
committed
Merge branch 'main' into s-object
2 parents 141e0c7 + 34d7e4d commit 192027f

68 files changed

Lines changed: 25914 additions & 25445 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/check_stub_files_diff.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v6
1818
- uses: prefix-dev/setup-pixi@v0.9.6
1919
with:
20-
pixi-version: v0.59.0
20+
pixi-version: v0.68.0
2121
frozen: true
2222

2323
- name: Check stub file for `_data_ops.py` is up-to-date

.github/workflows/run-code-format-checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v6
1818
- uses: prefix-dev/setup-pixi@v0.9.6
1919
with:
20-
pixi-version: v0.59.0
20+
pixi-version: v0.68.0
2121
frozen: true
2222

2323
- name: Run tests

.github/workflows/test-javascript.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v6
1616
- uses: prefix-dev/setup-pixi@v0.9.6
1717
with:
18-
pixi-version: v0.59.0
18+
pixi-version: v0.68.0
1919
environments: ci-py314-latest-optional-deps
2020
# we can freeze the environment and manually bump the dependencies to the
2121
# latest version time to time.

.github/workflows/testing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- uses: actions/checkout@v6
2828
- uses: prefix-dev/setup-pixi@v0.9.6
2929
with:
30-
pixi-version: v0.59.0
30+
pixi-version: v0.68.0
3131
environments: ${{ matrix.environment }}
3232
# we can freeze the environment and manually bump the dependencies to the
3333
# latest version time to time.
@@ -63,7 +63,7 @@ jobs:
6363
- uses: actions/checkout@v6
6464
- uses: prefix-dev/setup-pixi@v0.9.6
6565
with:
66-
pixi-version: v0.59.0
66+
pixi-version: v0.68.0
6767
environments: ci-nightly-deps
6868
# we can freeze the environment and manually bump the dependencies to the
6969
# latest version time to time.

.github/workflows/update_pixi_lock_files.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions/checkout@v6
2525
- uses: prefix-dev/setup-pixi@v0.9.6
2626
with:
27-
pixi-version: v0.59.0
27+
pixi-version: v0.68.0
2828
run-install: false
2929

3030
- name: Remove the current lock file

CHANGES.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,19 @@ New Features
4141
regular numeric format (``(432)`` becomes ``-432``). :pr:`1772` by :user:`Gabriela
4242
Gómez Jiménez <gabrielapgomezji>`.
4343
- Added :func:`skrub.selectors.object` to select columns with the ``object``
44-
(pandas) or ``pl.Object`` (polars) dtype. :pr:`2171`.
44+
(pandas) or ``pl.Object`` (polars) dtype. :pr:`2171` by :user:`Omkar Kabde
45+
<omkar-334>`.
46+
- :meth:`TableReport.json` now includes histogram data for numeric and datetime
47+
columns (the bin count and edges, and numbers of low and high outliers). Now
48+
``json()`` contains all the information shown in the report html rendering,
49+
including the plots. :pr:`2164` by :user:`Jérôme Dockès <jeromedockes>`.
4550

4651
Changes
4752
-------
48-
- :meth:`choose_from` now transparently converts `outcomes` to a list when it is another type of sequence. :pr:`2100` by
49-
:user:`aidbar <aidbar>`.
53+
- Grouped Examples into subject-specific sections. :pr:`2102` by
54+
:user:`Maureen Githaiga <maureen-githaiga>`.
55+
- :meth:`choose_from` now transparently converts `outcomes` to a list when it is
56+
another type of sequence. :pr:`2100` by :user:`aidbar <aidbar>`.
5057
- An unnecessary warning that was raised when passing a numpy array to the
5158
TableVectorizer has been removed. :pr:`1908` by
5259
:user:`Sandrine Henry <sandrineh>`.
@@ -66,8 +73,10 @@ Bugfixes
6673
durations to the total number of seconds (with fractional part). This is done
6774
by the new transformer :class:`DurationToFloat`. :pr:`2069` by
6875
:user:`Riccardo Cappuzzo <rcap107>`.
69-
70-
76+
- An error that could arise when running ``TableReport`` on dataframes containing
77+
double dollar (``$$``) signs has been fixed.
78+
:pr:`2154` by :user:`Katerina Michenina <Michenina-Lab>`,
79+
:user:`CecilyTS <CecilyTS>`, :user:`Eve Rabin <eve2705>`.
7180

7281
Deprecations
7382
------------
@@ -142,6 +151,9 @@ Changes
142151
<jeromedockes>`.
143152
- The ``exclude_cols`` of :meth:`DataOp.skb.apply` can now be a DataOp.
144153
:pr:`2050` by :user:`Jérôme Dockès <jeromedockes>`.
154+
- Skrub estimators now correctly show links to the documentation in the HTML
155+
representation that is generated for notebooks. :pr:`2036` by :user:`Riccardo
156+
Cappuzzo <rcap107>`.
145157

146158
Bugfixes
147159
--------

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"sphinx.ext.linkcode",
7171
"sphinx.ext.autodoc.typehints",
7272
# contrib
73+
"sphinx_design",
7374
"numpydoc",
7475
"sphinx_issues",
7576
"sphinx_copybutton",

doc/data_ops.rst

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,60 @@
11
.. _user_guide_data_ops_index:
22

3-
Complex multi-table pipelines with Data Ops
4-
===========================================
5-
6-
Skrub provides an easy way to build complex, flexible machine learning pipelines.
7-
There are several needs that are not easily addressed with standard scikit-learn
8-
tools such as :class:`~sklearn.pipeline.Pipeline` and
9-
:class:`~sklearn.compose.ColumnTransformer`, and for which the skrub DataOps offer
10-
a solution:
11-
12-
- Multiple tables: We often have several tables of different shapes (for
13-
example, "Customers", "Orders", and "Products" tables) that need to be
14-
processed and assembled into a design matrix ``X``. The target ``y`` may also
15-
be the result of some data processing. Standard scikit-learn estimators do not
16-
support this, as they expect right away a single design matrix ``X`` and a
17-
target array ``y``, with one row per observation.
18-
- DataFrame wrangling: Performing typical DataFrame operations such as
19-
projections, joins, and aggregations should be possible and allow leveraging
20-
the powerful and familiar APIs of `Pandas <https://pandas.pydata.org>`_ or
21-
`Polars <https://docs.pola.rs/>`_.
22-
- Hyperparameter tuning: Choices of estimators, hyperparameters, and even
23-
the pipeline architecture can be guided by validation scores. Specifying
24-
ranges of possible values outside of the pipeline itself (as in
25-
:class:`~sklearn.model_selection.GridSearchCV`) is difficult in complex
26-
pipelines.
27-
- Iterative development: Building a pipeline step by step while inspecting
28-
intermediate results allows for a short feedback loop and early discovery of
29-
errors.
30-
31-
In this section we cover all about the skrub Data Ops, from starting out with a
32-
simple example, to more advanced concepts like parameter tuning and and pipeline
33-
validation.
3+
.. currentmodule:: skrub
4+
5+
Building complete pipelines with DataOps
6+
========================================
7+
8+
A skrub DataOp is a complete machine learning pipeline —from data loading and
9+
wrangling to the final prediction— in a single object that can be fitted, tuned,
10+
cross-validated, and saved in a file like any scikit-learn estimator.
11+
12+
By integrating the whole data processing, DataOps help to validate pipelines
13+
while **avoiding data leakage**, to **tune complex modelling choices**, and to keep
14+
track of important **fitted (learned) state**.
15+
16+
To solve a machine-learning task we often need to combine multiple operations
17+
such as loading and filtering data, joining tables and computing aggregations,
18+
extracting numerical features, and fitting a classifier or regressor.
19+
20+
**Storing state**  Each of those operations may need to be fitted: to learn some
21+
information from training data and reuse it to apply consistent transformations
22+
to new data. This is the case for transformers like the
23+
:class:`~sklearn.preprocessing.StandardScaler` and :class:`TableVectorizer` and
24+
estimators like :class:`~sklearn.ensemble.RandomForestClassifier`.
25+
26+
**Tuning**  Moreover, each processing step may involve decisions that need to be
27+
tuned (*tuning* means finding the value that gives the best predictive
28+
performance), for example: what weather forecast features should I include to
29+
predict the load on an electric grid? How should I encode a product description
30+
to help predict the product's category? What learning rate to set on a
31+
:class:`~sklearn.ensemble.HistGradientBoostingRegressor`?
32+
33+
**Validation**  Finally, the quality of predictions must be evaluated on
34+
held-out data (with a train/test split or cross-validation), taking care to
35+
**avoid leakage** of test data into the training set.
36+
37+
Separating the data wrangling from the fitted estimator prevents correctly
38+
handling the tasks above. Skrub DataOps help by binding an arbitrary set of
39+
transformations of any number of inputs in a single estimator. These
40+
transformations can be easily parametrized with tunable choices. The resulting
41+
objects have built-in methods for cross-validation and tuning with either Optuna
42+
or scikit-learn, and for inspecting runs and intermediate results. Once fitted,
43+
they can be saved in a file, loaded, applied to new data as easily as a single
44+
:class:`~sklearn.linear_model.LogisticRegression`.
45+
46+
.. dropdown:: Going beyond the scikit-learn Pipeline
47+
:color: primary
48+
49+
To some extent, the DataOps exist for the same reasons as the simpler
50+
scikit-learn :class:`sklearn.pipeline.Pipeline` used in other parts of this
51+
documentation. However the Pipeline is too limited for many real-world problems:
52+
it can only represent a linear sequence of scikit-learn transformers, the design
53+
matrix and target variables must be constructed and divided into training and
54+
testing sets outside of the pipeline and the number of rows cannot change, only
55+
a single table can be handled, hyperparameter choices are difficult to define,
56+
etc. . Skrub DataOps remove those limitations and add several useful features
57+
such as interactive previews and integration with Optuna.
3458

3559
Data Ops basic concepts
3660
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

doc/guides/table_report/alter_appearance.rst renamed to doc/guides/table_report/01_alter_appearance.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
How to tweak the Appearance of the |TableReport|
88
------------------------------------------------
99

10-
The skrub global configuration includes various parameters that allow to tweak
10+
The skrub global configuration includes various parameters that let you tweak
1111
the HTML representation of the |TableReport|.
1212

1313
For performance reasons, the |TableReport| disables the computation of
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ It is also possible to export the raw HTML, or a HTML fragment to embed in a pag
2929
with :func:`~skrub.TableReport.html` and :func:`~skrub.TableReport.html_snippet`
3030
respectively.
3131

32-
Finally, it is possible to export the data in JSON format, which allows structured
32+
The report can be exported in JSON format, which allows structured
3333
access to the data and statistics used to build the report with
3434
:func:`~skrub.TableReport.json`.
3535

@@ -46,3 +46,16 @@ disabled directly when generating the table report.
4646
4747
tr = TableReport(df, plot_distributions=False)
4848
json_data = tr.json()
49+
50+
Finally, :func:`~skrub.TableReport.markdown` produces a shortened summary of the
51+
report in Markdown format. This summary contains the measured statistics and the
52+
associations (if measured): plots and table preview are skipped from this view.
53+
This format can be shared easily in text form, or fed to an AI agent to obtain
54+
insight about a given table.
55+
56+
.. warning::
57+
58+
No sanitization of the input data is performed, and the report includes raw data
59+
(column names and cell values). Therefore, it should not be used on untrusted data,
60+
or when the resulting summary may be too large as it could lead to security risks
61+
or performance problems.

0 commit comments

Comments
 (0)