-
Notifications
You must be signed in to change notification settings - Fork 423
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
Refactor/classification 10 #1197
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we also remove all the commented-out code like tests?
Yes. |
@SkafteNicki still draft? 😇 |
…chLightning/metrics into refactor/classification_10
Codecov Report
@@ Coverage Diff @@
## devel/classification #1197 +/- ##
======================================================
- Coverage 89% 50% -39%
======================================================
Files 191 191
Lines 10786 11201 +415
======================================================
- Hits 9577 5632 -3945
- Misses 1209 5569 +4360 |
@Borda ready for review |
for more information, see https://pre-commit.ci
Could you pls check the typing? |
@Borda not sure what to do about the typing. Take def jaccard_index(
preds: Tensor,
target: Tensor,
num_classes: int,
average: Optional[str] = "macro",
ignore_index: Optional[int] = None,
absent_score: float = 0.0,
threshold: float = 0.5,
task: Optional[Literal["binary", "multiclass", "multilabel"]] = None, # new arg
num_labels: Optional[int] = None, # new arg
validate_args: bool = True, # new arg
) -> Tensor:
if task is not None:
kwargs = dict(ignore_index=ignore_index, validate_args=validate_args)
if task == "binary":
return binary_jaccard_index(preds, target, threshold, **kwargs)
if task == "multiclass":
return multiclass_jaccard_index(preds, target, num_classes, average, **kwargs)
if task == "multilabel":
return multilabel_jaccard_index(preds, target, num_labels, threshold, average, **kwargs)
raise ValueError(
f"Expected argument `task` to either be `'binary'`, `'multiclass'` or `'multilabel'` but got {task}"
)
else:
rank_zero_warn(
...
DeprecationWarning,
)
confmat = _confusion_matrix_update(preds, target, num_classes, threshold)
return _jaccard_from_confmat(confmat, num_classes, average, ignore_index, absent_score) The new argument |
* example * stat scores * revert * remove old tests * deprecate binned * remove init * warning functionals * docs update * add __new__ for class wrapping * update imports in docstrings * fix one mistake * fix doctests * Apply suggestions from code review * elif * kwargs * kwargs + elif * text * fix gpu testing Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Jirka <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* example * stat scores * revert * remove old tests * deprecate binned * remove init * warning functionals * docs update * add __new__ for class wrapping * update imports in docstrings * fix one mistake * fix doctests * Apply suggestions from code review * elif * kwargs * kwargs + elif * text * fix gpu testing Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Jirka <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* example * stat scores * revert * remove old tests * deprecate binned * remove init * warning functionals * docs update * add __new__ for class wrapping * update imports in docstrings * fix one mistake * fix doctests * Apply suggestions from code review * elif * kwargs * kwargs + elif * text * fix gpu testing Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Jirka <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* example * stat scores * revert * remove old tests * deprecate binned * remove init * warning functionals * docs update * add __new__ for class wrapping * update imports in docstrings * fix one mistake * fix doctests * Apply suggestions from code review * elif * kwargs * kwargs + elif * text * fix gpu testing Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Jirka <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
What does this PR do?
Continues work on classification refactor #1001
Prior work:
This PR is introducing the changes for the transition (deprecation) of the old API to the new.
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃