8000 change the tuple order in make_column_transformer by adrinjalali · Pull Request #12626 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

change the tuple order in make_column_transformer #12626

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
merged 3 commits into from
Nov 21, 2018

Conversation

adrinjalali
Copy link
Member

Fixes #12396
Fixes #12339

Change the expected tuple order in make_column_transformer to (transformer, columns).

@adrinjalali
Copy link
Member Author

I've left PR #12396 the way it is for us to see both solutions (just in case there's any doubts) and for the reference in case questions come up in the future.

@amueller
Copy link
Member

thanks. Whatsnew?

@adrinjalali
Copy link
Member Author

oh yeah, forgot that, on it!

@amueller
Copy link
Member

Sweet, thanks!

Copy link
Contributor
@eamanu eamanu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member
@ogrisel ogrisel left a comment
8000

Choose a reason for hiding this comment

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

Tiny nitpick to check that fit_transform still works with the deprecated call. Other than that +1 on my side.

with pytest.warns(DeprecationWarning,
match='`make_column_transformer` now expects'):
make_column_transformer(('passthrough', 'passthrough'),
('first', 'drop'))
Copy link
Member

Choose a reason for hiding this comment

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

Please add a check that the output of fit_transform with this tuple order is the same as the output of fit_transform with the non deprecated tuple order.

@amueller amueller added this to the 0.20.1 milestone Nov 20, 2018
@@ -48,6 +48,10 @@ Changelog
even if all transformation results are sparse. :issue:`12304` by `Andreas
Müller`_.

- |API| :func:`compose.make_column_transformer` now expects
`(transformer, columns)` instead of `(columns, transformer)`.
:issue:`12339` by :user:`Adrin Jalali <adrinjalali>`.
Copy link
Member

Choose a reason for hiding this comment

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

I would add something like "to be consistent with ColumnTransformer"

# XXX remove in v0.22
with pytest.warns(DeprecationWarning,
match='`make_column_transformer` now expects'):
make_column_transformer(('first', scaler))
Copy link
Member

Choose a reason for hiding this comment

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

Should we check here that the resulting ColumnTransformer has the correct order? (or at least once)

@jnothman
Copy link
Member

(Would it hurt if someone else wrapped this up, so that it can be released? I'm guessing @adrinjalali is now afk.)

Copy link
Member
@qinhanmin2014 qinhanmin2014 left a comment

Choose a reason for hiding this comment

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

LGTM. I prefer this solution because
(1) The code is simple, thus much easier to maintain
(2) I guess ColumnTransformer is used more often, so maybe it will be better to change make_column_transformer
Will merge when green

make_column_transformer(('first', scaler))
ct1 = make_column_transformer(([0], norm))
ct2 = make_column_transformer((norm, [0]))
X_array = np.array([[0, 1, 2], [2, 4, 6]]).T
Copy link
Member

Choose a reason for hiding this comment

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

I think that @jorisvandenbossche meant the correct order of (transformer, column), not the correct order of data... but I suppose this confirms that it's behaving as expected at least.

Copy link
Member

Choose a reason for hiding this comment

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

and actually I'm addressing @ogrisel's comment here, see #12626 (comment) :)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that tests that as well :)

@qinhanmin2014
Copy link
Member

I think that @jorisvandenbossche meant the correct order of (transformer, column), not the correct order of data... but I suppose this confirms that it's behaving as expected at least.

Hmm, but seems that it's not related to the deprecation and we've already have some tests to ensure the correct order (e.g., test_column_transformer_mixed_cols_sparse)? I'll merge this one so that we can release, we can always have some other PRs if needed.

@qinhanmin2014 qinhanmin2014 merged commit a816af7 into scikit-learn:master Nov 21, 2018
@qinhanmin2014
Copy link
Member

thanks @adrinjalali

jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Nov 21, 2018
@adrinjalali adrinjalali deleted the api/ct-order2 branch November 21, 2018 08:42
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
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.

7 participants
0