Skip to content

Parallelize the GapEncoder - #582

Merged
GaelVaroquaux merged 3 commits into
skrub-data:mainfrom
LilianBoulard:parallelize_gap_columns
Jun 11, 2023
Merged

GaelVaroquaux merged 3 commits into
skrub-data:mainfrom
LilianBoulard:parallelize_gap_columns

Conversation

@LilianBoulard

@LilianBoulard LilianBoulard commented Jun 9, 2023 •

Copy link
Copy Markdown
Member

Implements parallelization of the GapEncoder column-wise, as it is currently a simple for loop.
This could speed up the process significantly for wide datasets (intuitively, to be benchmarked).

@LilianBoulard LilianBoulard added the enhancement New feature or request label Jun 9, 2023
@LilianBoulard LilianBoulard self-assigned this Jun 9, 2023
@LilianBoulard LilianBoulard changed the title Parallelize the Gap column-wise Parallelize the GapEncoder Jun 9, 2023

@Vincent-Maladiere Vincent-Maladiere 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.

Hey @LilianBoulard! We might want to chose n_jobs based on the number of columns and the number of available core.

The _partition_estimator function from sklearn could be insightful :)

https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/ensemble/_base.py#L216-L226

@GaelVaroquaux

GaelVaroquaux commented Jun 9, 2023 via email

Copy link
Copy Markdown
Member

@Vincent-Maladiere

Copy link
Copy Markdown
Member

We never set parallelism on by default, because it can too easily lead to overcommit (eg with nested objects that have parallelism).

Ok, so what about the predict methods of RandomForest in sklearn?

https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/ensemble/_forest.py#L866

In case the user does set n_jobs, wouldn't it be good to provide some heuristics?

@GaelVaroquaux

Copy link
Copy Markdown
Member

In case the user does set n_jobs, wouldn't it be good to provide some heuristics?

That's a good point. The code in RandomForest is there to create bunches of estimators. This is useful when there are many more iterations than CPUs. I do not think that it will be useful here.

@tomMoral

Copy link
Copy Markdown

Aha not sure if I am an expert but here is my 2cts:

joblib is auto batching so it should already be not too bad. But if you find instances on which auto batching does not work well, please report them so we can try to improve the heuristic for every joblib users 😁

Also note that if possible, it is best to not change the n_jobs too much in different parts of the pipeline as this might cause respawning/resizing the executor, which is slow for fast running examples. If you really have an heuristic that works well, it is better to keep n_jobs the same but create smart batches (except if you intend to play with lower level parallelism, but in this case, tell me more 🙃)

@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.

LGTM. I made a tiny suggestion, but I will just merge it, and than merge this PR

Comment thread skrub/_gap_encoder.py Resolved
@GaelVaroquaux
GaelVaroquaux merged commit 44a63a3 into skrub-data:main Jun 11, 2023
Vincent-Maladiere pushed a commit that referenced this pull request Jun 12, 2023
* Parallelize the Gap column-wise

* Add changelog entry

* Update skrub/_gap_encoder.py

---------

Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
@LilianBoulard
LilianBoulard deleted the parallelize_gap_columns branch June 12, 2023 11:30
GaelVaroquaux added a commit that referenced this pull request Jun 12, 2023
* Quick bootstrap

* misc

* fix contributing link

* stabilize current LP layout

* add skrub banner

* replace banner with the target

* center feature blocks

* replace banner with the pipeline

* enable transparent bg for banner

* add skrub banner

* remove secondary sidebar

* DOC: landing page is jinja, not rst (#589)

* fall back to pandas if no datetime format is found (#587)

* fall back to pandas if no datetime format is found

* change changelog

* Fix X shape in minhash_encoder docstrings (#584)

* Parallelize the `GapEncoder` (#582)

* Parallelize the Gap column-wise

* Add changelog entry

* Update skrub/_gap_encoder.py

---------

Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>

* fix fetching params (#591)

* remove index.rst

* add empty but toctree index.rst

---------

Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
Co-authored-by: LeoGrin <45738728+LeoGrin@users.noreply.github.com>
Co-authored-by: Lilian <lilian@boulard.fr>
Co-authored-by: Jovan Stojanovic <62058944+jovan-stojanovic@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants