Comments (5)
The reason that the ColumnTransform creates one job per transformer is that some transformers can be multivariate (for instance a PCA, or a feature selection=.
I do see your point that parallel computing could be much improved by special casing a few encoders, such as the GapEncoder that must be parallelized.
The challenge in my eyes is: how to do this. One approach is to override the "_iter" method of the ColumnTransformer, in a way similar to (pseudo-code, won't run):
UNIVARIATE_TRANSFORMERS = (GapEncoder, MinHashEncoder)
...
def _iter(self, fitted=False, replace_strings=False, column_as_strings=False):
for (name, trans, columns, get_weight(name)) in ColumnTransformer._iter(self, fitted=fitted, replace_strings=replace_strings, column_as_strings=column_as_strings)
if isinstance(trans, UNIVARIATE_TRANSFORMERS):
for column in columns:
yield (name, trans, (column, ), get_weight(name))
else:
yield (name, trans, columns, get_weight(name))
This will need to be very extensively tested, as we are going to be toying with internals (_iter is a private function, and we are clearly putting our fingers a bit deep inside scikit-learn's private code).
from skrub.
Thanks ! Another solution which might be simpler: find all transformers with the n_jobs
attribute, and set it manually. I'm wondering how simple it is to combine this and the ColumnTransformer
's parallelism (doesn't seem to work very well when I do it naively on current TableVectorizer).
What do you think? Here's the pseudo-code I have in mind:
for (name, trans, columns) in self.transformers:
if trans.has_attribute("n_jobs"):
trans.n_jobs = len(columns) #assuming we have a lot of cores, should be set better
self.n_jobs = #override if necessary
from skrub.
from skrub.
If we want to avoid nested parallelism, something which would be very simple while still being an improvement is to set the TableVectorizer
n_jobs to 1, and pass the n_jobs argument to all transformers which have this attribute. This would be faster than what we have now (usually more columns of each type than transformers). And in the current situation, where high-cardinality transformers are much slower than the other transformers, it should be close to your solution in term of performance. What do you think about implementing this right now, and eventually going back to your solution if the situation changes?
from skrub.
Summarizing the meeting discussion, two possibility:
- If all transformers have
n_jobs
attributes and theirn_jobs
=None, pass the n_jobs arguments to the transformers and set TableVectorizer.n_jobs to 1. Pro: Benefits from some encoders parallelism (e.g MinHashEncoder). Cons: surprising for the user. - Overrite the "_iter" method. Pro: less surprising, more jobs being created. Cons: Dependance on a sklearn private function.
The second method was chosen.
from skrub.
Related Issues (20)
- FEAT Develop the `AggJoiner` and `AggTarget` HOT 8
- Interactive examples for skrub HOT 4
- BUG example 03 breaks with `exact_until='microsecond'`
- FEAT Getting only the time since epoch from the DateTimeEncoder
- BUG DateTimeEncoder fails when `extract_until` is "year" or "month" HOT 2
- BUG DateTimeEncoder fails when a column mixes formats HOT 3
- DOC visual inconsistencies with the last version of the PyData Theme
- Adding a transformer to sessionize a table HOT 5
- Jupyterlite kernel fails to launch HOT 4
- DOC Remove file-level flake8 noqa HOT 1
- Use `Joiner` in `fuzzy_join` rather than the opposite
- `match_score` used in example 4 is too low to reject any matches
- Joiner's match score threshold varies with each call to transform HOT 1
- fuzzy_join's match_score starts at 0.5 not 0.0 HOT 4
- division by 0 in fuzzy_join when there are only perfect matches HOT 4
- DOC Remove `filterwarnings` from some examples HOT 10
- ENH Improve `DatetimeEncoder` HOT 3
- Support Polars dataframes across the library HOT 4
- Missing values support is not consistent HOT 8
- Add `doc/sg_execution_times.rst` to `.gitignore`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skrub.