-
Notifications
You must be signed in to change notification settings - Fork 345
Add CAG validation to synthesizer.validate #2480
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
base: feature/single-table-CAG
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/single-table-CAG #2480 +/- ##
============================================================
+ Coverage 98.54% 98.59% +0.04%
============================================================
Files 68 68
Lines 7030 7048 +18
============================================================
+ Hits 6928 6949 +21
+ Misses 102 99 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
202aa7b
to
d955a9e
Compare
12ec5bc
to
c2c3060
Compare
c2c3060
to
258e10a
Compare
b62ec68
to
14d9936
Compare
14d9936
to
6e7813e
Compare
74f045e
to
85b506c
Compare
sdv/single_table/base.py
Outdated
@@ -775,31 +768,51 @@ def _transform_helper(self, data): | |||
|
|||
return data | |||
|
|||
def preprocess(self, data): | |||
"""Transform the raw data to numerical space. | |||
def _validate_cags(self, data): |
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 this function just call the user-facing validate_cag
function (made for synthetic data)?
Line 719 in 85b506c
def validate_cag(self, synthetic_data): |
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.
On second thought, these two functions seem slightly different.
sdv/multi_table/base.py
Outdated
@@ -348,6 +345,19 @@ def _validate_all_tables(self, data): | |||
|
|||
return errors | |||
|
|||
def _validate_cags(self, data): |
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.
can we either call this _validate_cag
or _validate_constraints
. CAG stands fore constraint augmented generation and isn't plural.
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 renamed it _validate_cag
for now since there is an existing _validate_constraints
that handles old-style constraints. I will name it _validate_constraints
when solving #2492
@@ -501,7 +483,6 @@ def get_info(self): | |||
return info | |||
|
|||
def _preprocess(self, data): | |||
self.validate(data) |
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.
why did we move validate out of here?
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.
We moved it out because _preprocess() is defined only in the BaseSynthesizer while all the cag logic is defined in the BaseSingleTableSynthesizer. That's why I added a _preprocess_helper method (similar to transform_helper()) that handles the cag.
9eba42f
to
7347cc6
Compare
157d027
to
61cb10e
Compare
if hasattr(self, '_reject_sampling_patterns'): | ||
for pattern in self._reject_sampling_patterns: | ||
pattern.validate(data=data, metadata=self._original_metadata) | ||
|
||
Returns: | ||
pandas.DataFrame: | ||
The preprocessed data. | ||
if hasattr(self, '_chained_patterns'): | ||
for pattern in self._chained_patterns: | ||
pattern.fit(data=data, metadata=metadata) | ||
metadata = pattern.get_updated_metadata(metadata) | ||
data = pattern.transform(data) |
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.
this code looks very similar to the following. Should we combine them?
https://github.com/sdv-dev/SDV/blob/b6ebea53595679ad6acafbaee37d16f46e335fc1/sdv/single_table/base.py#L813C1-L819C64
CU-86b4pmjph
Resolve #2470