8000 [MRG+1] Fix inverse_transform in deprecated GridSearchCV by MrMjauh · Pull Request #8860 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG+1] Fix inverse_transform in deprecated GridSearchCV #8860

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 4 commits into from
May 12, 2017
Merged

[MRG+1] Fix inverse_transform in deprecated GridSearchCV #8860

merged 4 commits into from
May 12, 2017

Conversation

MrMjauh
Copy link
@MrMjauh MrMjauh commented May 11, 2017

Reference Issue

Fixes #8846

What does this implement/fix? Explain your changes.

Calling the right function in the method inverse_transform(self,Xt) in grid_search.py

Any other comments?

First try contributing!

Copy link
Member
@lesteve lesteve left a comment

Choose a reason for hiding this comment

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

I would advise you to look closely at https://github.com/scikit-learn/scikit-learn/pull/8348/files and do something very similar. This will be a lot quicker to review this way.

In particular you can update the existing whats_new.rst entry saying that the same bug was fixed for sklearn.grid_search.GridSearchCV.

@@ -71,9 +71,16 @@ def fit(self, X, Y):
def predict(self, T):
return T.shape[0]

def transform(self,T):
T = T - 2;
Copy link
Member

Choose a reason for hiding this comment

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

This is Python, you don't need ; at the end of the lines.

Copy link
Author

Choose a reason for hiding this comment

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

Sweet, will look at it!

T = T - 2;
return T;

def inverse_transform(self,T):
Copy link
Member

Choose a reason for hiding this comment

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

PEP8 -> def inverse_transform(self, T):

# Test the transform operations
transformed = grid_search.transform(X)
reverse_transformed = grid_search.inverse_transform(transformed)
assert_equal(np.array_equal(reverse_transformed, X), True)
Copy link
Member

Choose a reason for hiding this comment

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

You have to use assert_array_equal() instead of assert_equal(np.array_equal())

Tips: when you want to compare with True, there is assert_true sklearn.utils.testing

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, did not know those functions existed, will look more closely into your linked url.

@@ -71,9 +71,16 @@ def fit(self, X, Y):
def predict(self, T):
return T.shape[0]

def transform(self,T):
Copy link
Member

Choose a reason for hiding this comment

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

PEP8 ->def transform(self, T):

@glemaitre
Copy link
Member

I would advise you to look closely at https://github.com/scikit-learn/scikit-learn/pull/8348/files and do something very similar. This will be a lot quicker to review this way.
In particular you can update the existing whats_new.rst entry saying that the same bug was fixed for sklearn.grid_search.GridSearchCV.

+1

Copy link
Member
@TomDLT TomDLT left a comment

Choose a reason for hiding this comment

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

Except the change in whats_new that needs to be fixed, LGTM

@@ -172,6 +172,10 @@ Enhancements
:issue:`7674` by:user:`Yichuan Liu <yl565>`.

Bug fixes

- Fixed a bug where :func:`sklearn.grid_search.BaseSearchCV.inverse_transform`
Copy link
Member

Choose a reason for hiding this comment

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

You should not add it between Bug fixes and ..........

By the way, you could probably merge this entry with the one of Akshay0724 4 entries below, which was exactly the same on a different file.

@@ -802,4 +815,4 @@ def test_classes__property():
# Test that regressors do not have a classes_ attribute
grid_search = GridSearchCV(Ridge(), {'alpha': [1.0, 2.0]})
grid_search.fit(X, y)
assert_false(hasattr(grid_search, 'classes_'))
assert_false(hasattr(grid_search, 'classes_'))
Copy link
Member

Choose a reason for hiding this comment

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

please do not remove the last empty line

@TomDLT TomDLT changed the title Fixes #8846, calling the right transform function [MRG+1] Fix inverse_transform in deprecated GridSearchCV May 11, 2017
@lesteve
Copy link
Member
lesteve commented May 12, 2017

LGTM merging, thanks a lot!

@lesteve lesteve merged commit 6413feb into scikit-learn:master May 12, 2017
@MrMjauh MrMjauh deleted the gridsearch_inverse_transform_function branch May 22, 2017 13:20
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
NelleV pushed a commit to NelleV/scikit-learn that referenced this pull request Aug 11, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
AishwaryaRK pushed a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
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.

GridSearchCV inv_transform calls transform instead of inv_transform on best_estimator_
4 participants
0