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 ReferentialIntegrity metric #461

Closed
frances-h opened this issue Oct 9, 2023 · 0 comments · Fixed by #499
Closed

Add ReferentialIntegrity metric #461

frances-h opened this issue Oct 9, 2023 · 0 comments · Fixed by #499
Assignees
Labels
feature request Request for a new feature
Milestone

Comments

@frances-h
Copy link
Contributor

frances-h commented Oct 9, 2023

Problem Description

As a user, I would like a metric that checks the integrity of my inter-table relationships.

Expected behavior

  • Add a new column_pairs metric that calculates the percent of foreign keys values that reference a real parent value.
  • This metric takes in primary key and foreign key column pairs.

Attributes

The metric should have the following attributes:

  • name: 'ReferentialIntegrity'
  • goal: Goal.MAXIMIZE
  • min_value: 0.0
  • max_value: 1.0

Methods

The metric should also define the following methods

  • compute(real_data, synthetic_data): Compute the score for the metric. The returned score should be the percent of foreign key values that reference a value in the primary key column.
    • Parameters:
      • (required) real_data: a tuple of 2 pandas.Series objects. The first is the primary key column and the second is the foreign key column from the real data. (Note that this is different than other column_pair metrics)
      • (required) synthetic_data: a tuple of 2 pandas.Series objects. The first is the primary key column and the second is the foreign key column from the synthetic data. (Note that this is different than other column_pair metrics)
    • Returns: The score for the metric
>>> from sdmetrics.column_pairs import ReferentialIntegrity
>>> ReferentialIntegrity.compute(
	real_data=(real['users']['id'], real['sessions']['user_id']),
	synthetic_data=(synth['users']['id'], synth['sessions']['user_id'])
1.0
>>> ReferentialIntegrity.compute_breakdown(
	real_data=(real['users']['id'], real['sessions']['user_id']),
	synthetic_data=(synth['users']['id'], synth['sessions']['user_id'])
{ 'score': 1.0 }
@frances-h frances-h added feature request Request for a new feature new Label applied to new issues labels Oct 9, 2023
@amontanez24 amontanez24 removed the new Label applied to new issues label Oct 23, 2023
@amontanez24 amontanez24 added this to the 0.13.0 milestone Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants