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

Add random state #204

Merged
merged 8 commits into from
Feb 18, 2022
Merged

Add random state #204

merged 8 commits into from
Feb 18, 2022

Conversation

katxiao
Copy link
Contributor

@katxiao katxiao commented Feb 8, 2022

Add random state field to CTGAN and TVAE models.

  • Add setter for random_state on base class
  • Create random_state decorator to use around sampling methods
  • Add unit tests

@katxiao katxiao requested a review from a team as a code owner February 8, 2022 18:06
@katxiao katxiao requested review from pvk-developer and csala and removed request for a team February 8, 2022 18:06
@katxiao katxiao force-pushed the add-random-state branch 2 times, most recently from 2235d35 to 6a855bb Compare February 8, 2022 19:23
Copy link
Contributor

@csala csala left a comment

Choose a reason for hiding this comment

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

Added a few comments. The ones added to sdv-dev/Copulas#313 should be considered as well.

Also, I think that integration tests should be added to ensure that the effect of setting the seed is the expected one.

ctgan/synthesizers/ctgan.py Show resolved Hide resolved
import torch


@contextlib.contextmanager
def set_random_state(random_state, set_model_random_state):
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this uses torch, should we be setting the torch seed too?

Copy link
Member

@pvk-developer pvk-developer 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 the torch seed, which concerns me as well, I think this looks good. Here is a resource regarding randomness on pytorch : https://pytorch.org/docs/stable/notes/randomness.html

@codecov-commenter
Copy link

codecov-commenter commented Feb 17, 2022

Codecov Report

Merging #204 (91a1d48) into master (7f307fc) will increase coverage by 2.63%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #204      +/-   ##
==========================================
+ Coverage   36.09%   38.73%   +2.63%     
==========================================
  Files          10       10              
  Lines         676      710      +34     
==========================================
+ Hits          244      275      +31     
- Misses        432      435       +3     
Impacted Files Coverage Δ
ctgan/synthesizers/base.py 75.55% <90.62%> (+37.09%) ⬆️
ctgan/synthesizers/ctgan.py 49.36% <100.00%> (+0.21%) ⬆️
ctgan/synthesizers/tvae.py 18.75% <100.00%> (+0.73%) ⬆️

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 7f307fc...91a1d48. Read the comment docs.

Copy link
Contributor

@csala csala left a comment

Choose a reason for hiding this comment

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

I added a couple minor comments, but other than that this looks ready to go

ctgan/synthesizers/base.py Outdated Show resolved Hide resolved
ctgan/synthesizers/base.py Outdated Show resolved Hide resolved
ctgan/synthesizers/base.py Outdated Show resolved Hide resolved
@katxiao katxiao merged commit 6244e0b into master Feb 18, 2022
@katxiao katxiao deleted the add-random-state branch February 18, 2022 00:26
@katxiao katxiao added this to the 0.5.1 milestone Feb 25, 2022
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