Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG] FIX passthrough parameter from make_column_transformer to ColumnTransformer #11183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

glemaitre
Copy link
Member

Stumble in an issue with the make_column_transformer which is missing the remainder parameter.
I added the parameter. I don't think that we need a what's new.

@glemaitre
Copy link
Member Author

Note that I did not pass the transformer_weights since it seems something that we don't do in the make_* function (cf make_union).

So my question is: do we still not pass the weight and keep the current PR or just pass **kwargs to the constructor which will fail with a similar error message with unknown keywords.

ping @jnothman @jorisvandenbossche @amueller

@amueller
Copy link
Member

amueller commented Jun 1, 2018

this is not tested?

@amueller
Copy link
Member

amueller commented Jun 1, 2018

I don't understand the remark, maybe @jnothman remembers? I don't think the argument is very useful/important but I also don't see a good reason to leave it out.

@glemaitre
Copy link
Member Author

this is not tested?

Speaking @jorisvandenbossche, make_column_transformer is tested but just forgot to add this option.

@jorisvandenbossche
Copy link
Member

So to clarify the remark of Guillaume (#11183 (comment)). The make_column_transformer code currently does not pass through all keywords it gets on purpose.
This behaviour is mimicking the behaviour of make_union, where also the weights are not passed through.

And when I added the remainder keyword, I forgot to add this to make_column_transformer explicitily, as of course this keyword is much more important than the weights.

However, if we don't care about the fact that weights should/can not be specified in the make_ function, we can simplify the code by simply removing all manual kwarg handling and just passing through the **kwargs to the ColumnTransformer constructor.

@jnothman
Copy link
Member

jnothman commented Jun 2, 2018 via email

@glemaitre
Copy link
Member Author

OK, so I forwarded all parameters and removed the check. It will be catch by the __init__ of the ColumnTransformer.

@glemaitre glemaitre changed the title FIX passthrough "remainder" param in make_column_transformer FIX passthrough parameter from make_column_transformer to ColumnTransformer Jun 4, 2018
@glemaitre glemaitre changed the title FIX passthrough parameter from make_column_transformer to ColumnTransformer [MRG] FIX passthrough parameter from make_column_transformer to ColumnTransformer Jun 4, 2018
make_column_transformer, ('first', scaler), (['second'], norm),
transformer_weights={'pca': 10, 'Transf': 1}
)
assert_equal(ct.remainder, 'drop')
Copy link
Member

Choose a reason for hiding this comment

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

also add a similar check for transformer_weights ?

Copy link
Member Author

Choose a reason for hiding this comment

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

ups

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

No, we can't have transformer_names under that specification. It assumes the user knows how to transform the transformers list into their automatically-assigned names, which we shouldn't have to document for such a rarely used feature... Get rid of weights

@jorisvandenbossche
Copy link
Member

No, we can't have transformer_names under that specification. It assumes the user knows how to transform the transformers list into their automatically-assigned names,

Aha, so that was the reasoning we were looking for to understand how it was done this way originally! :-)

But indeed, makes sense, so then we only pass through n_jobs and remainder

@glemaitre glemaitre force-pushed the quick_fix_make_column_transformer branch from ea18574 to 4ffdbcd Compare June 5, 2018 08:01
@glemaitre
Copy link
Member Author

OK, I revert it back to only pass n_jobs and remainder

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -595,6 +595,15 @@ def make_column_transformer(*transformers, **kwargs):
----------
*transformers : tuples of column selections and transformers

remainder : {'passthrough', 'drop'}, default 'passthrough'
By default, all remaining columns that were not specified in
`transformers` will be automatically passed through (default of
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: double backticks around "transformers".

Copy link
Member

Choose a reason for hiding this comment

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

ignore, I did not know about the controversy.

@ogrisel ogrisel merged commit 41651a1 into scikit-learn:master Jun 6, 2018
jorisvandenbossche added a commit to jorisvandenbossche/scikit-learn that referenced this pull request Sep 25, 2018
Follow-up on scikit-learn#12152
And added comment why transformer_weights is not passed through, see
scikit-learn#11183 (review)
for more discussion
qinhanmin2014 pushed a commit that referenced this pull request Sep 25, 2018
Follow-up on #12152
And added comment why transformer_weights is not passed through, see
#11183 (review)
for more discussion
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Oct 15, 2018
…2156)

Follow-up on scikit-learn#12152
And added comment why transformer_weights is not passed through, see
scikit-learn#11183 (review)
for more discussion
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.

5 participants