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

Feature metric jsd (#66) #71

Merged
merged 7 commits into from
Dec 18, 2023
Merged

Conversation

MooooCat
Copy link
Contributor

@MooooCat MooooCat commented Dec 18, 2023

  • [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

  • Apply suggestions from code review

  • jsd

  • jsd

  • [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

  • base更新

  • [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

  • Delete .idea directory

Description

The JSD single column metric.

Motivation and Context

Since the base class of metric(Branch: feature-metric-base) has not yet been merged into the main branch, this JSD branch will first merge into the feature metric base and then merge into the main branch.

Due to changes in some components, it is necessary to make some modifications to the examples before merging.

Types of changes

  • Maintenance (no change in code, maintain the project's CI, docs, etc.)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* jsd

* jsd

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* base更新

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Delete .idea directory

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: MoooCat <141886018+MooooCat@users.noreply.github.com>
Co-authored-by: Zhongsheng Ji <9573586@qq.com>
Copy link
Contributor

sweep-ai bot commented Dec 18, 2023

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.
  • Apply: Add docstrings to all functions and file headers.

sdgx/metrics/multi_table/base.py Outdated Show resolved Hide resolved
self.metric_name = "jensen_shannon_divergence"

@classmethod
def calculate(cls, real_data, synthetic_data, discrete, cols):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest add some type hint here

sdgx/metrics/column/base.py Outdated Show resolved Hide resolved
sdgx/metrics/column/base.py Outdated Show resolved Hide resolved
sdgx/metrics/column/base.py Outdated Show resolved Hide resolved
Co-authored-by: Zhongsheng Ji <9573586@qq.com>
@MooooCat
Copy link
Contributor Author

Thanks to @Wh1isper for the carefully review. I will add some descriptive comments for input parameters in the method calculate.

@Wh1isper
Copy link
Collaborator

Wh1isper commented Dec 18, 2023

Actually type hint and docstring are all we need

Like we did in https://github.com/hitsz-ids/synthetic-data-generator/blob/main/sdgx/data_processors/base.py

Example:

# type hint example

# For python 3.8 and 3.9
from __future__ import annotations

@classmethod
def calculate(cls, real_data: pd.DataFrame, synthetic_data: pd.DataFrame, discrete: list[str] | None, cols: list[str] | None) -> pd.DataFrame:
"""
What is this function

Args:
  real_data (pd.DataFrame): balabala...
  ....

"""

@Wh1isper
Copy link
Collaborator

Wh1isper commented Dec 18, 2023

Actually type hint and docstring are all we need

Like we did in main/sdgx/data_processors/base.py

Example:

# type hint example

# For python 3.8 and 3.9
from __future__ import annotations 

@classmethod
def calculate(cls, real_data: pd.DataFrame, synthetic_data: pd.DataFrame, discrete: list[str] | None, cols: list[str] | None) -> pd.DataFrame:
"""
What is this function

Args:
  real_data (pd.DataFrame): balabala...
  ....

"""

I'd be inclined to add this to all public methods, especially those that require subclass implementation. This is very intuitive for developers and users, and allows static checking tools to work well.

sdgx/metrics/column/base.py Outdated Show resolved Hide resolved
sdgx/metrics/column/jsd.py Outdated Show resolved Hide resolved
sdgx/metrics/column/jsd.py Outdated Show resolved Hide resolved
sdgx/metrics/single_table/base.py Outdated Show resolved Hide resolved
MooooCat and others added 2 commits December 18, 2023 11:56
Co-authored-by: Zhongsheng Ji <9573586@qq.com>
@MooooCat MooooCat marked this pull request as ready for review December 18, 2023 03:57
Copy link
Collaborator

@Wh1isper Wh1isper left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@MooooCat MooooCat merged commit 9e040d3 into feature-metric-base Dec 18, 2023
2 checks passed
MooooCat added a commit that referenced this pull request Dec 18, 2023
* Update metric base-class

* Update column metric base class

* Update Metric Base Class

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* Feature: Add metric jsd (#66) (#71)

* Feature metric jsd (#66)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* jsd

* jsd

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* base更新

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Delete .idea directory

---------


Co-authored-by: Jinhang Su <171846802@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: MoooCat <141886018+MooooCat@users.noreply.github.com>
Co-authored-by: Zhongsheng Ji <9573586@qq.com>


* Apply suggestions from code review

Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* Update type hint and comments.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------


Co-authored-by: Jinhang Su <171846802@qq.com>
Co-authored-by: sjh120 <171846802@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix typo error

unnecessary imports are also removed.

* Add type hints and comments

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update input check methods

The format of some codes has also been adjusted.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Zhongsheng Ji <9573586@qq.com>
Co-authored-by: Jinhang Su <171846802@qq.com>
Wh1isper added a commit that referenced this pull request Dec 18, 2023
* Update metric base-class

* Update column metric base class

* Update Metric Base Class

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* Feature: Add metric jsd (#66) (#71)

* Feature metric jsd (#66)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* jsd

* jsd

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* base更新

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Delete .idea directory

---------


Co-authored-by: Jinhang Su <171846802@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: MoooCat <141886018+MooooCat@users.noreply.github.com>
Co-authored-by: Zhongsheng Ji <9573586@qq.com>


* Apply suggestions from code review

Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* Update type hint and comments.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------


Co-authored-by: Jinhang Su <171846802@qq.com>
Co-authored-by: sjh120 <171846802@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Zhongsheng Ji <9573586@qq.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix typo error

unnecessary imports are also removed.

* Add type hints and comments

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update input check methods

The format of some codes has also been adjusted.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Zhongsheng Ji <9573586@qq.com>
Co-authored-by: Jinhang Su <171846802@qq.com>
@MooooCat MooooCat deleted the feature-metric-jsd branch December 19, 2023 14:50
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.

3 participants