Skip to content

Adding Gamma poisson factorization - #153

Merged
alexis-cvetkov merged 24 commits into
skrub-data:masterfrom
alexis-cvetkov:gamma_poisson
Feb 6, 2021
Merged

alexis-cvetkov merged 24 commits into
skrub-data:masterfrom
alexis-cvetkov:gamma_poisson

Conversation

@alexis-cvetkov

Copy link
Copy Markdown
Contributor

Changes:

  • Added gamma_poisson_factorization.py which implements online Gamma-Poisson factorization for encoding string variables.
  • Added the corresponding tests intest_gamma_poisson_factorization.
  • Modified examples 02 and 03 to include this method.
  • Updated CHANGES.rst and index.rst to describe this new method.

@GaelVaroquaux

Copy link
Copy Markdown
Member

Wohoo!!

@Phaide : can you have a look when you have time?

Have a look at the code, the test (it's OK if you don't understand everything, this is a sophisticated mathematical algorithm. Check that you understand how to use this, that it feels natural, that the examples make sense, that it's well referenced in the docs (we should point from SimilarityEncoder to this for large datasets). Thanks!!!!

Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
@alexis-cvetkov

alexis-cvetkov commented Dec 3, 2020 •

Copy link
Copy Markdown
Contributor Author

Following the error on travis, the sklearn version is checked when importing the "k-means++" init method and the _beta_divergence method to account for different file and method names across versions.

@LilianBoulard LilianBoulard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very good !
Thanks @alexis-cvetkov, good work !

The code is clean and fairly documented (though a few more inline comments to explain complex operations would be welcome!).
One last request: as mentioned by Gaël, could you please consider adding a little notice in the SimilarityEncoder docstring ?
Thanks again !

@amy12xx

amy12xx commented Dec 5, 2020

Copy link
Copy Markdown
Contributor

Great to see this addition. I look forward to going through the code when I have a bit more time.

@alexis-cvetkov

Copy link
Copy Markdown
Contributor Author

Thank you for the review @Phaide, I have added more documentation in the code for gamma-poisson factorization, and a little docstring in similarity_encoder.py.
This PR looks ready for merge to me now !

@LilianBoulard LilianBoulard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me !
@amy12xx could you please have a quick look before merging ?
Thanks !

@amy12xx amy12xx left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great @alexis-cvetkov . I left a few minor comments. And one other general comment: I wonder if it is a good convention to have the referenced methods above the referenced ones (for e.g. the non-class functions before the class definition).

Comment thread CHANGES.rst Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated

@GaelVaroquaux GaelVaroquaux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here are a bunch of cosmetic comments.

I'll try to come back and check the algorithmics, but we had checked them back when we coded this originally.

Thanks for the hard work!

Comment thread CHANGES.rst Outdated
Comment thread CHANGES.rst Outdated
Comment thread CHANGES.rst Outdated
Comment thread dirty_cat/test/test_gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/test/test_gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
@GaelVaroquaux

GaelVaroquaux commented Dec 15, 2020 via email

Copy link
Copy Markdown
Member

@GaelVaroquaux

GaelVaroquaux commented Dec 15, 2020 via email

Copy link
Copy Markdown
Member

@alexis-cvetkov

Copy link
Copy Markdown
Contributor Author

CircleCI is not building anymore. I think this is because it now uses python 3.9 during the build, and some packages like scikit-learn do not support it yet.

Update: I pinned the version of python to 3.8 in build_doc.sh. I don't know if it's the right way to fix this but it works!

@amy12xx amy12xx left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Regarding my list comprehension comment, I had something like this in mind: self.H_dict = {x: h for x, h in zip(X, H)} but I think I assumed that H_dict would have the exact same elements as X. If this is not the case, you can ignore this comment.

Comment thread dirty_cat/gamma_poisson_factorization.py Outdated
@GaelVaroquaux

GaelVaroquaux commented Dec 16, 2020 via email

Copy link
Copy Markdown
Member

@amy12xx

amy12xx commented Dec 17, 2020

Copy link
Copy Markdown
Contributor

Thanks @alexis-cvetkov . Looks good to me.

@GaelVaroquaux GaelVaroquaux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot for the PR. I finally had time to review it in depth.

I made a bunch of inline comments. On top of these, I have a few bigger picture comments:

  • We need to add a comment at the top of the "Scalability considerations" example saying that the GapEncoder is naturally scalable and should be preferred for large-scale data.
  • We should restore the get_feature_names method and demo it in one of the examples
  • We should restore the partial_fit method and demo it in a new example on scalability

Thanks!!!

Comment thread examples/02_fit_predict_plot_employee_salaries.py Outdated
Comment thread examples/02_fit_predict_plot_employee_salaries.py Outdated
Comment thread examples/03_fit_predict_plot_midwest_survey.py Outdated
Comment thread examples/03_fit_predict_plot_midwest_survey.py Outdated
Comment thread build_tools/circle/build_doc.sh Outdated
Comment thread dirty_cat/gap_encoder.py
Comment thread dirty_cat/gap_encoder.py Outdated
Comment thread dirty_cat/gap_encoder.py Outdated
Comment thread dirty_cat/gap_encoder.py Outdated
Comment thread dirty_cat/gap_encoder.py Outdated
@GaelVaroquaux

GaelVaroquaux commented Feb 2, 2021 via email

Copy link
Copy Markdown
Member

@alexis-cvetkov

alexis-cvetkov commented Feb 2, 2021 •

Copy link
Copy Markdown
Contributor Author

It implies that every call to fit has a clean start, independent of the past.

Okay, I was confused by the test you proposed:

if not hasattr(self, "H_dict"):
    ...

In this case I don't need to test if H_dict exist but I can simply re-initialize it everytime fit is called
For partial_fit however I can use this test to init H_dict once and update it for the following calls of partial_fit.

@GaelVaroquaux

GaelVaroquaux commented Feb 2, 2021 via email

Copy link
Copy Markdown
Member

@GaelVaroquaux

Copy link
Copy Markdown
Member

@alexis-cvetkov : careful, I am pushing to your branch. If you work on this, pull first.

@GaelVaroquaux

Copy link
Copy Markdown
Member

I believe that this is now good to go. I will merge when the tests have run. Thanks!!!

@alexis-cvetkov

Copy link
Copy Markdown
Contributor Author

Great ! Thank you !

@alexis-cvetkov
alexis-cvetkov merged commit 63156fa into skrub-data:master Feb 6, 2021
@alexis-cvetkov
alexis-cvetkov deleted the gamma_poisson branch February 6, 2021 10:47
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.

4 participants