8000 [MRG+1] Bug in BaseSearchCV.inverse_transform by Akshay0724 · Pull Request #8348 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG+1] Bug in BaseSearchCV.inverse_transform #8348

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 8 commits into from
Feb 17, 2017

Conversation

Akshay0724
Copy link
Contributor

Reference Issue

Fixes #8344

What does this implement/fix? Explain your changes.

Code for inverse transform function in BaseSearchCV was written incorrect, I have changed it from .transform(Xt) to .inverse_transform(Xt)

Any other comments?

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.

Please add a test and an entry in what's new. Thanks.

@codecov
Copy link
codecov bot commented Feb 13, 2017

Codecov Report

Merging #8348 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #8348      +/-   ##
==========================================
+ Coverage   94.75%   94.75%   +<.01%     
==========================================
  Files         342      342              
  Lines       60801    60809       +8     
==========================================
+ Hits        57609    57617       +8     
  Misses       3192     3192
Impacted Files Coverage Δ
sklearn/model_selection/_search.py 97.88% <100%> (ø)
sklearn/model_selection/tests/test_search.py 99.31% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8694278...0766a6b. Read the comment docs.

@Akshay0724
Copy link
Contributor Author

Please give me some pointers, how I shall start writing test.

@TomDLT
Copy link
Member
TomDLT commented Feb 13, 2017

You should write a test in sklearn/model_selection/tests/test_search.py.
The idea is to write the simplest example that used to fail, but that does not fail anymore.

Then you should add an entry on the bug fix list doc/whats_new.rst

@Akshay0724
Copy link
Contributor Author

In test_search.py there is a dummy MockClassifier() class that is used for testing. Should adding a dummy inverse_transform() and transform() function to it and using them in a test looks correct ?

@jnothman
Copy link
Member
jnothman commented Feb 17, 2017 via email

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.

Other than this two small comments LGTM


grid_search.fit(X, y)
inverse_transform = grid_search.inverse_transform(X)
assert_array_equal(X, 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.

Rather than assuming what inverse_transform is I think it would be better to check that inverse_transform(transform(X)) == X.

You could implement transform to be X + self.foo_param and inverse_transform to be X - self.foo_param for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have committed these changes please have a look. Thanks

- Fixed a bug where :class:`sklearn.linear_model.RandomizedLasso` and
:class:`sklearn.linear_model.RandomizedLogisticRegression` breaks for
sparse input.
:issue:`8259` by :user:`Aman Dalmia <dalmia>`.


Copy link
Member

Choose a reason for hiding this comment

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

Best practice: don't change code unless there is a very good reason to. Remove the new line you added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, that was by mistake.

Copy link
Member

Choose a reason for hiding this comment

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

No problem, but it's always good to review your diff before and/or after commit to reduce diff noise like this.

@TomDLT TomDLT changed the title [MRG] Bug in BaseSearchCV.inverse_transform [MRG+1] Bug in BaseSearchCV.inverse_transform Feb 17, 2017
@lesteve
Copy link
Member
lesteve commented Feb 17, 2017

I pushed a small naming improvement in your branch, merging thanks a lot !

@lesteve lesteve merged commit 676e863 into scikit-learn:master Feb 17, 2017
@Akshay0724
Copy link
Contributor Author

Thanks for merging @lesteve.

sergeyf pushed a commit to sergeyf/scikit-learn that referenced this pull request Feb 28, 2017
@Przemo10 Przemo10 mentioned this pull request Mar 17, 2017
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 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
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
lemonlaug pushed a commit to lemonlaug/scikit-learn that referenced this pull request Jan 6, 2021
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.

Bug in BaseSearchCV.inverse_transform
4 participants
0