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 correlation similarity metric #158

Merged
merged 5 commits into from
Jul 20, 2022

Conversation

katxiao
Copy link
Contributor

@katxiao katxiao commented Jul 14, 2022

Resolves #143

@katxiao katxiao requested a review from a team as a code owner July 14, 2022 16:30
@katxiao katxiao requested review from amontanez24 and removed request for a team July 14, 2022 16:30
@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2022

Codecov Report

Merging #158 (5846cc6) into master (5ef643f) will increase coverage by 0.62%.
The diff coverage is 83.67%.

@@            Coverage Diff             @@
##           master     #158      +/-   ##
==========================================
+ Coverage   58.06%   58.68%   +0.62%     
==========================================
  Files          59       60       +1     
  Lines        1774     1813      +39     
==========================================
+ Hits         1030     1064      +34     
- Misses        744      749       +5     
Impacted Files Coverage Δ
.../single_column/statistical/statistic_similarity.py 73.52% <66.66%> (-0.76%) ⬇️
...column_pairs/statistical/correlation_similarity.py 84.84% <84.84%> (ø)
sdmetrics/column_pairs/base.py 91.66% <100.00%> (+2.77%) ⬆️
sdmetrics/column_pairs/statistical/__init__.py 100.00% <100.00%> (ø)
sdmetrics/single_table/multi_column_pairs.py 65.85% <100.00%> (+2.69%) ⬆️

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 5ef643f...5846cc6. Read the comment docs.

Copy link
Contributor

@amontanez24 amontanez24 left a comment

Choose a reason for hiding this comment

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

Some minor comments about datetime handling/testing. Besides that this looks good!

synthetic_data[pd.isna(synthetic_data)] = 0.0
column1, column2 = real_data.columns[:2]

if is_datetime(real_data):
Copy link
Contributor

Choose a reason for hiding this comment

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

should we error if synthetic data isn't also datetime?

Copy link
Contributor Author

@katxiao katxiao Jul 18, 2022

Choose a reason for hiding this comment

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

Hm so I have a couple thoughts -

  1. This handling is used in many metrics across the column_pairs and single_column metrics. I do think it would be nice to add more comprehensive validation. I'm not sure if it's worth adding it in this PR, since that will make it less unified.
  2. Most of the usage should be through single table metrics, which filters all the metrics by data type, and only applies the relevant metrics. In this use case, we should always be applying the correct metric for a given data type. That's why I don't think it's a huge issue right now. Of course, people can still choose to directly invoke the column pair metric.

I'm in favor of opening another issue around adding data type verification on the base classes of ColumnPairMetric and SingleColumnMetric, and addressing it for all metrics. Let me know what you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, added an issue for tracking here: #168

import pandas as pd


class DataFrameMatcher:
Copy link
Contributor

Choose a reason for hiding this comment

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

are these classes being added for future use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I just added it here in case we need it in the future, since it seemed likely that we would match a data frame at some point.

class TestCorrelationSimilarity:

@patch('sdmetrics.column_pairs.statistical.correlation_similarity.pearsonr')
def test_compute_breakdown(self, pearson_mock):
Copy link
Contributor

Choose a reason for hiding this comment

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

can we do an example with datetime columns?

@katxiao katxiao force-pushed the issue-143-add-correlation-similarity-metric branch from 0141130 to 5846cc6 Compare July 20, 2022 18:48
@katxiao katxiao merged commit 3c72e85 into master Jul 20, 2022
@katxiao katxiao deleted the issue-143-add-correlation-similarity-metric branch July 20, 2022 22:54
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.

Add CorrelationSimilarity metric
3 participants