Skip to content
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

[MRG+1] FIX Pickled sample_weights in BinaryTree #11774

Merged
merged 5 commits into from Aug 9, 2018

Conversation

Projects
None yet
3 participants
@NicolasHug
Copy link
Contributor

NicolasHug commented Aug 7, 2018

Reference Issues/PRs

Fixes #11769

What does this implement/fix? Explain your changes.

This PR adds the sample_weight attribute to the list of pickled attributes of BinaryTree, which fixes bugs such as the one in #11769.

Also, pickled KDTree and BallTree instances now keep their classes. Before, they would become BinaryTree objects.

Any other comments?

I added a basic test which is basically the sample code in #11769, but this is only testing a side effect of the changes. I'm not sure what could be more relevant here.

@qinhanmin2014

This comment has been minimized.

Copy link
Member

qinhanmin2014 commented Aug 8, 2018

Thanks @NicolasHug for the PR
(1) Seems that the regression is introduced in #10803. We have a common test (check_estimators_pickle) but seems not enough since KernelDensity doesn't have predict/transform/predict_proba/decision_function
(2) @NicolasHug I'm fine with current test but maybe we can use pickle instead of joblib here
(3) ping @jnothman @TomDLT for the regression

@qinhanmin2014 qinhanmin2014 changed the title [MRG] Pickled sample_weights in BinaryTree [MRG+1] FIX Pickled sample_weights in BinaryTree Aug 8, 2018

@qinhanmin2014 qinhanmin2014 added this to the 0.20 milestone Aug 8, 2018

@jnothman
Copy link
Member

jnothman left a comment

Nice work debugging

joblib.dump(kde, file_path)
kde = joblib.load(file_path)
scores_pickled = kde.score_samples(X)

This comment has been minimized.

Copy link
@jnothman

jnothman Aug 8, 2018

Member

To be sure, can you check that the tree is of the right type?

This comment has been minimized.

Copy link
@NicolasHug

NicolasHug Aug 8, 2018

Author Contributor

Thanks I missed that one.

It was an issue in BinaryTree and dates back as far as 226fe51 !

NicolasHug added some commits Aug 8, 2018

Pickled BallTree and KDTree now keep their class
Prior to this change, they would become a generic BinaryTree object
@jnothman

This comment has been minimized.

Copy link
Member

jnothman commented Aug 8, 2018

Good work!

Please add an entry to the change log at doc/whats_new/v0.20.rst. Like the other entries there, please reference this pull request with :issue: and credit yourself (and other contributors if applicable) with :user:

NicolasHug added some commits Aug 9, 2018

@jnothman jnothman merged commit d990f72 into scikit-learn:master Aug 9, 2018

3 of 5 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
ci/circleci: deploy Your tests passed on CircleCI!
Details
ci/circleci: python2 Your tests passed on CircleCI!
Details
ci/circleci: python3 Your tests passed on CircleCI!
Details
@jnothman

This comment has been minimized.

Copy link
Member

jnothman commented Aug 9, 2018

Thanks a lot @NicolasHug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.