-
Notifications
You must be signed in to change notification settings - Fork 322
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
Allow me to access loss values for GAN-based synthesizers #1681
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
import numpy as np | ||
|
||
from sdv.errors import SynthesizerInputError | ||
from sdv.errors import NotFittedError, SynthesizerInputError | ||
|
||
TMP_FILE_NAME = '.sample.csv.temp' | ||
DISABLE_TMP_FILE = 'disable' | ||
|
@@ -349,3 +349,23 @@ def log_numerical_distributions_error(numerical_distributions, processed_data_co | |
f"cannot be applied to column '{column}' because it no longer " | ||
'exists after preprocessing.' | ||
) | ||
|
||
|
||
class GANMixin: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you feel about putting this class in the ctgan file since all the gans are already there? Also I think VAEs aren't technically GANs. Maybe we should change the name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to |
||
"""Mixin class for GAN-based synthesizers.""" | ||
|
||
def get_loss_values(self): | ||
"""Get the loss values from the model. | ||
|
||
Raises: | ||
- ``NotFittedError`` if synthesizer has not been fitted. | ||
|
||
Returns: | ||
pd.DataFrame: | ||
Dataframe containing the loss values per epoch. | ||
""" | ||
if not self._fitted: | ||
err_msg = 'Loss values are not available yet. Please fit your synthesizer first.' | ||
raise NotFittedError(err_msg) | ||
|
||
return self._model.loss_values.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we error if the table name is bad? I think there is an error message we use in a lot of places for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we usually use
_validate_table_name
but the full error message doesn't really make sense in this context, so I used an edited version.