8000 [MRG] Save sample_weight_arr instead of sample_weight in KernelDensity by aditya1702 · Pull Request #13772 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG] Save sample_weight_arr instead of sample_weight in KernelDensity #13772

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 15 commits into from
May 14, 2019

Conversation

aditya1702
Copy link
Contributor

Reference Issues/PRs

Fixes #13692

What does this implement/fix? Explain your changes.

Saves the sample_weight_arr instead of sample_weight. This enables the KernelDensity model object to be dumped into a pickle file. Also adds the relevant test for this.

@aditya1702
Copy link
Contributor Author

@jnothman @NicolasHug Can be merged

@aditya1702 aditya1702 changed the title [WIP] Save sample_weight_arr instead of sample_weight in KernelDensity [MRG] Save sample_weight_arr instead of sample_weight in KernelDensity May 4, 2019
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.

This looks correct, though I'm wondering if we're doing the wrong thing to not try make pickles backwards compatible (by making the sample_weight entry in the pickle optional)... Though this is not really due to your PR.
I'd like it if the storing of memory views and sum_weight was refactored into a helper method to avoid duplication in init and setstate.

@aditya1702
Copy link
Contributor Author

This looks correct, though I'm wondering if we're doing the wrong thing to not try make pickles backwards compatible (by making the sample_weight entry in the pickle optional)... Though this is not really due to your PR.
I'd like it if the storing of memory views and sum_weight was refactored into a helper method to avoid duplication in init and setstate.

@jnothman So you mean that if we dont supply sample_weight during fit, we should not be pickling sample_weight_arr?

@jnothman
Copy link
Member
jnothman commented May 5, 2019 via email

@aditya1702
Copy link
Contributor Author

No, I mean that if there are only 12 elements in the pickle state we can set the sample_weight to None.

@jnothman Wont there always be 12 elements in the pickle? We are pickling sample_weight_arr irrespective of whether we are supplying sample_weight or not

@jnothman
Copy link
Member
jnothman commented May 5, 2019 via email

@jnothman
Copy link
Member
jnothman commented May 5, 2019 via email

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.

I'd still prefer some refactoring, but otherwise this lgtm

@aditya1702
Copy link
Contributor Author

I'd still prefer some refactoring, but otherwise this lgtm

@jnothman Where do you want to do refactoring?

@jnothman
Copy link
Member
jnothman commented May 9, 2019 via email

@Dathiou
Copy link
Dathiou commented May 9, 2019

@jnothman @aditya1702 thank you for the fix! do you have an estimate on when it will be released?

@aditya1702
Copy link
Contributor Author

@jnothman @aditya1702 thank you for the fix! do you have an estimate on when it will be released?

@Dathiou @jnothman I am currently busy with my final semester exams. Will refactor and make the changes after 15th.

@ogrisel
Copy link
Member
ogrisel commented May 13, 2019

I pushed a commit to address some of @jnothman's comments. Let's see if the CI likes it.

@jnothman
Copy link
Member
jnothman commented May 14, 2019 via email

@ogrisel ogrisel merged commit 36e4fda into scikit-learn:master May 14, 2019
@ogrisel ogrisel added this to the 0.21.1 milestone May 14, 2019
@ogrisel
Copy link
Member
ogrisel commented May 14, 2019

Merged! Thanks @aditya1702 for your contribution. @jnothman I let you take care of the 0.21.1 backport.

jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request May 14, 2019
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request May 14, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
@jnothman jnothman modified the milestones: 0.21.1, 0.20.4 Jul 23, 2019
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Jul 23, 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.

Saving KernelDensity with sample_weight
5 participants
0