8000 feat(doctest): precision metric doctest by halsawadi · Pull Request #2306 · pytorch/ignite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(doctest): precision metric doctest #2306

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

Closed
wants to merge 1 commit into from

Conversation

halsawadi
Copy link
@halsawadi halsawadi commented Oct 29, 2021

Fixes part of #2265

Description:

Add a doctest for Precision in the metrics module.

Check list:

  • New tests are added (if a new feature is added)
  • New doc strings: description and/or example code are in RST format
  • Documentation is updated (if required)

@github-actions github-actions bot added the module: metrics Metrics module label Oct 29, 2021
@vfdev-5
Copy link
Collaborator
vfdev-5 commented Oct 29, 2021

@ydcjeff could you please review this PR

@ydcjeff
Copy link
Contributor
ydcjeff commented Oct 30, 2021

Code looks good. @halsawadi Can you change the description of the PR to something like reference #2265 or part of #2265 because this PR doesn't fix the issue entirely.

Thanks.

Comment on lines +95 to +100
def thresholded_output_transform(engine, output):
y_pred, y = output
y_pred = torch.round(y_pred)
return y_pred, y
engine = Engine(thresholded_output_transform)
metric = Precision()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if this is what we want to expose to our users. thresholded_output_transform should remain the argument to Precision and not for Engine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually that should be process_function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The example shows how to binarize predictions for Precision metric only. Returning binarized preds from validator may be a limitation...

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general we can improve the docstring for Precision (same for Accuracy and this comment: #2287 (comment)) and show all possible cases:

binary case
multiclass case
multilabel case


def thresholded_output_transform(output):
def thresholded_output_transform(engine, output):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def thresholded_output_transform(engine, output):
def process_fn(engine, output):

8000
y_pred, y = output
y_pred = torch.round(y_pred)
return y_pred, y
engine = Engine(thresholded_output_transform)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
engine = Engine(thresholded_output_transform)
engine = Engine(process_fn)

@sdesrozis
Copy link
Contributor

@halsawadi Thank you for your work. Are you still working on this ?

@sdesrozis
Copy link
Contributor

@halsawadi Thank you for your help. I close this PR since the doctest for Precision has been merged.

@sdesrozis sdesrozis closed this Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: metrics Metrics module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0