Skip to content

Issue 2921 and 2920 overlaping check - #2938

Open
nemanja-vujic wants to merge 4 commits into
mainfrom
issue-2921-and-2920-overlaping-check
Open

Issue 2921 and 2920 overlaping check#2938
nemanja-vujic wants to merge 4 commits into
mainfrom
issue-2921-and-2920-overlaping-check

Conversation

@nemanja-vujic

Copy link
Copy Markdown

Add utils.py with two functions that measure how much the synthetic data reuses values from the real data.

get_combination_overlap counts combinations of column values that appear in both datasets

get_pii_overlap does the same for the values of a single PII column.

Resolves #2921
Resolves #2920

Add utils.py with two functions that measure how much the synthetic data reuses values from the real data.

get_combination_overlap counts combinations of column values that appear in both datasets

get_pii_overlap does the same for the values of a single PII column.

Resolves #2921
Resolves #2920
Add utils.py with two functions that measure how much the synthetic data reuses values from the real data.

get_combination_overlap counts combinations of column values that appear in both datasets

get_pii_overlap does the same for the values of a single PII column.

Resolves #2921
Resolves #2920
@nemanja-vujic
nemanja-vujic requested a review from a team as a code owner August 4, 2026 16:34
@nemanja-vujic
nemanja-vujic requested review from sarahmish and removed request for a team August 4, 2026 16:34
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.08%. Comparing base (d41a08a) to head (3ce817d).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2938      +/-   ##
==========================================
+ Coverage   98.06%   98.08%   +0.01%     
==========================================
  Files          75       76       +1     
  Lines        8589     8655      +66     
==========================================
+ Hits         8423     8489      +66     
  Misses        166      166              
Flag Coverage Δ
integration 76.46% <74.24%> (-0.02%) ⬇️
unit 97.08% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nemanja-vujic nemanja-vujic self-assigned this Aug 4, 2026
Comment thread sdv/evaluation/utils.py
)


def _validate_data(real_data, synthetic_data, table_name, column_names):

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.

maybe add a validation to check:

  • table_name is a string
  • column_names is a list of strings

Comment thread sdv/evaluation/utils.py Outdated
if verbose:
print(f'Number of common combinations: {num_common} ({percent}%)') # noqa: T201
if num_common == 0:
print(NO_OVERLAP_MESSAGE) # noqa: T201

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.

you can use sys.stdout.write instead of print

Comment thread sdv/evaluation/utils.py Outdated

MISSING_VALUE_PLACEHOLDER = '__sdv_missing_value__'

NO_OVERLAP_MESSAGE = (

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.

nit: since these messages are only used once, I would prefer to move them inside the function that uses them instead of creating a constant variable.

Comment thread sdv/evaluation/utils.py
real_values = real_data[table_name][column_names].copy()
synthetic_values = synthetic_data[table_name][column_names].copy()
for column_name in column_names:
real_values[column_name], synthetic_values[column_name] = _align_dtypes(

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.

is this step necessary given that all the columns will be casted as 'object' in _get_combinations?

# Assert
real_combinations = set(real_data[column_names].itertuples(index=False, name=None))
assert isinstance(result, int)
assert 0 <= result <= len(real_combinations)

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.

isn't the upper limit here the union of the unique combinations of real and synthetic?

Comment thread tests/unit/evaluation/test_utils.py Outdated
return {'table': real_table}, {'table': synthetic_table}


class TestGetCombinations:

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.

If we are testing a function, then the test will be written as a function. If we are testing a class, then the test will be written as a class.

In this case, _get_combinations is a function and the test function definition should be something like test_{function_name}_{purpose_of_test}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants