Skip to content

Expose ApplyToCols and ApplyToFrame - #1478

Merged
GaelVaroquaux merged 12 commits into
skrub-data:mainfrom
Vincent-Maladiere:apply_on_cols
Jul 11, 2025
Merged

Expose ApplyToCols and ApplyToFrame#1478
GaelVaroquaux merged 12 commits into
skrub-data:mainfrom
Vincent-Maladiere:apply_on_cols

Conversation

@Vincent-Maladiere

Copy link
Copy Markdown
Member

Fixes #1429

@rcap107

rcap107 commented Jun 27, 2025

Copy link
Copy Markdown
Member

This will be a fun one to review

@Vincent-Maladiere

Copy link
Copy Markdown
Member Author

ahahah indeed. I apologised in advance

@jeromedockes

Copy link
Copy Markdown
Member

ahahah indeed. I apologised in advance

😅 thanks for plowing through

from ._join_utils import pick_column_names

__all__ = ["OnEachColumn", "SingleColumnTransformer", "RejectColumn"]
__all__ = ["ApplyToCols", "SingleColumnTransformer", "RejectColumn"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

total nitpick: maybe I would name that file _apply_to_cols.py?

@GaelVaroquaux

Copy link
Copy Markdown
Member

Is this ready to review / merge?

@rcap107

rcap107 commented Jul 9, 2025

Copy link
Copy Markdown
Member

I'll review this tomorrow, I haven't had the time yet

@GaelVaroquaux

GaelVaroquaux commented Jul 9, 2025 via email

Copy link
Copy Markdown
Member

Comment thread skrub/_apply_to_frame.py Outdated
Comment thread skrub/_apply_to_frame.py Outdated
Co-authored-by: Riccardo Cappuzzo <7548232+rcap107@users.noreply.github.com>
Comment thread examples/10_apply_on_cols.py Outdated
Comment thread examples/10_apply_on_cols.py Outdated
Comment thread examples/10_apply_on_cols.py Outdated
Comment thread examples/10_apply_on_cols.py Outdated
Comment thread examples/10_apply_on_cols.py Outdated
Comment thread examples/10_apply_on_cols.py Outdated
Xt

# %%
# Let's now imagine that our two previous columns ``"division"``,

@rcap107 rcap107 Jul 10, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced by this phrasing: either they are highly correlated (which they do not seem to be, from the associations) and so there is a reason for this operation, or they aren't. If they aren't, I think adding an imaginary reason would just add to confusion: it's an example, I think that showing what is happening is more useful

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll simplify the narrative

Comment thread examples/10_apply_on_cols.py Outdated
Comment thread examples/10_apply_on_cols.py Outdated
Comment thread examples/10_apply_on_cols.py Outdated
Comment thread examples/10_apply_on_cols.py Outdated
#
# This time, we can use :class:`~skrub.ApplyToFrame`, which applies a transformer to
# columns jointly, rather than separately like :class:`~skrub.ApplyToCols`.
#

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful to be more explicit, something like

This is useful for transformers that work on multiple columns at once, such as the PCA that we want to use to reduce the number of components.

Comment thread examples/10_apply_on_cols.py Outdated
Comment thread examples/10_apply_on_cols.py Outdated
# We define a column filter using skrub selectors with a lambda function.
from sklearn.preprocessing import OrdinalEncoder

low_cardinality = s.filter(lambda col: col.nunique() < 40)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that selectors include .cardinality_below, I think there should either be a mention to the function ("this can also be done with .cardinality_below"), or a different example should be used

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I can mention it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we address this?

(I also want terribly to merge, because this is very useful. If I merge too fast, maybe address in a new PR)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it has been adressed in the text section above, L97:

# We define a column filter using skrub selectors with a lambda function. Note that
# the same effect can be obtained directly by using
# :func:`~srkub.selectors.cardinality_below`.

@rcap107 rcap107 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @Vincent-Maladiere, I went over all the files and they look good

Most of my comments are about the example, but overall it looks good 👍

Vincent-Maladiere and others added 3 commits July 10, 2025 13:36
Co-authored-by: Riccardo Cappuzzo <7548232+rcap107@users.noreply.github.com>

@rcap107 rcap107 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks a lot @Vincent-Maladiere

Comment thread examples/10_apply_on_cols.py Outdated

@GaelVaroquaux GaelVaroquaux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging!

Thanks a lot. This is a big deall

@GaelVaroquaux
GaelVaroquaux merged commit f982f32 into skrub-data:main Jul 11, 2025
26 checks passed
MarieSacksick pushed a commit to MarieSacksick/skrub that referenced this pull request Jul 18, 2025
Co-authored-by: Riccardo Cappuzzo <7548232+rcap107@users.noreply.github.com>
MarieSacksick pushed a commit to MarieSacksick/skrub that referenced this pull request Jul 18, 2025
Co-authored-by: Riccardo Cappuzzo <7548232+rcap107@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose OnEachColumn and OnSubFrame

4 participants