8000 [MRG+1] FIX Pickled sample_weights in BinaryTree by NicolasHug · Pull Request #11774 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

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

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 5 commits into from
Aug 9, 2018

Conversation

NicolasHug
Copy link
Member
@NicolasHug 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
Copy link
Member

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
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.

Nice work debugging

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

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks I missed that one.

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

@jnothman
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:

@jnothman jnothman merged commit d990f72 into scikit-learn:master Aug 9, 2018
@jnothman
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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

saving a KernelDensity estimator
3 participants
0