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

[ENH] Replace prts metrics #2400

Merged
merged 48 commits into from
Mar 21, 2025
Merged

Conversation

aryanpola
Copy link
Contributor

@aryanpola aryanpola commented Nov 26, 2024

Reference Issues/PRs

Addresses #2066

What does this implement/fix? Explain your changes.

Implementation of Precision, Recall and F1-score metrics.

PR checklist

For all contributions
  • I've added myself to the list of contributors. Alternatively, you can use the @all-contributors bot to do this for you.
  • The PR title starts with either [ENH], [MNT], [DOC], [BUG], [REF], [DEP] or [GOV] indicating whether the PR topic is related to enhancement, maintenance, documentation, bugs, refactoring, deprecation or governance.

@aeon-actions-bot aeon-actions-bot bot added benchmarking Benchmarking package enhancement New feature, improvement request or other non-bug code enhancement labels Nov 26, 2024
@aeon-actions-bot
Copy link
Contributor

Thank you for contributing to aeon

I have added the following labels to this PR based on the title: [ $\color{#FEF1BE}{\textsf{enhancement}}$ ].
I have added the following labels to this PR based on the changes made: [ $\color{#264F59}{\textsf{benchmarking}}$ ]. Feel free to change these if they do not properly represent the PR.

The Checks tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.

If our pre-commit code quality check fails, any trivial fixes will automatically be pushed to your PR unless it is a draft.

Don't hesitate to ask questions on the aeon Slack channel if you have any.

PR CI actions

These checkboxes will add labels to enable/disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.

  • Run pre-commit checks for all files
  • Run mypy typecheck tests
  • Run all pytest tests and configurations
  • Run all notebook example tests
  • Run numba-disabled codecov tests
  • Stop automatic pre-commit fixes (always disabled for drafts)
  • Disable numba cache loading
  • Push an empty commit to re-run CI checks

@aryanpola aryanpola marked this pull request as draft November 26, 2024 05:43
@MatthewMiddlehurst MatthewMiddlehurst changed the title Recall [ENH] [ENH] Recall Nov 26, 2024
Copy link
Member

@MatthewMiddlehurst MatthewMiddlehurst left a comment

Choose a reason for hiding this comment

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

Some of these functions look like they should be private/protected. In the tests please run both the new and current functions to ensure the output is the same (using pytest)

@MatthewMiddlehurst MatthewMiddlehurst changed the title [ENH] Recall [ENH] Replace prts metrics Dec 27, 2024
@aryanpola
Copy link
Contributor Author

Changes made from the previous commit:

  1. Added a function for flattening lists of lists into a list.
  2. Removes overlapping functions.
  3. Changed the metric calculations from averaging(w.r.t cardinality) to global(w.r.t overlapping positions) calculation of real and pred ranges.

@aryanpola aryanpola marked this pull request as ready for review December 30, 2024 18:41
@aryanpola
Copy link
Contributor Author

@MatthewMiddlehurst Please let me know if the test cases are fine, I can separate them into different functions if necessary.

@TonyBagnall
Copy link
Contributor

thanks for this, its really helpful. We will look again next week

@aryanpola
Copy link
Contributor Author

@MatthewMiddlehurst @SebastianSchmidl , I’ve updated the test cases so that they now compare the current implementation with the prts package for all parameter configurations.

@SebastianSchmidl
Copy link
Member

SebastianSchmidl commented Feb 21, 2025

Please add a check for the soft-dependency "prts" to those test where you call into the existing range-based metrics to make the CI happy; similar to the existing tests:

@pytest.mark.skipif(
not _check_soft_dependencies("prts", severity="none"),
reason="required soft dependency prts not available",
)
def test_range_based_p_range_based_r_auc_perfect_hit():

@aryanpola
Copy link
Contributor Author

Please add a check for the soft-dependency "prts" to those test where you call into the existing range-based metrics to make the CI happy; similar to the existing tests:

@pytest.mark.skipif(
not _check_soft_dependencies("prts", severity="none"),
reason="required soft dependency prts not available",
)
def test_range_based_p_range_based_r_auc_perfect_hit():

Done. Let me know if there's anything else to be changed.

Copy link
Member

@MatthewMiddlehurst MatthewMiddlehurst left a comment

Choose a reason for hiding this comment

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

Thanks a lot for addressing my concerns. I'm happy for this to go in the with testing done.

I would not close the issue yet, the next step is to remove the old functions and prts as a dependency. Unfortunately, this would involve changing a lot of the testing you have done here again, but the main purpose of the output comparison is to smooth the transition anyway.

Copy link
Member

@SebastianSchmidl SebastianSchmidl left a comment

Choose a reason for hiding this comment

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

Just some small documentation changes

@aryanpola
Copy link
Contributor Author

aryanpola commented Feb 25, 2025

@MatthewMiddlehurst @SebastianSchmidl
Further changes to be made:

  1. Remove prts from all_extras
  2. Update tests to compare the implementation output with hard-coded values (already done in previous commits).
  3. Remove the older function, which includes aeon\benchmarking\metrics\anomaly_detection\_binary.py. aeon\benchmarking\metrics\anomaly_detection\_continuous.py still uses prts as a dependency. What should be done with that?

This should be everything?

@SebastianSchmidl
Copy link
Member

@MatthewMiddlehurst @SebastianSchmidl Further changes to be made:

  1. Remove prts from all_extras
  2. Update tests to compare the implementation output with hard-coded values (already done in previous commits).
  3. Remove the older function, which includes aeon\benchmarking\metrics\anomaly_detection\_binary.py. aeon\benchmarking\metrics\anomaly_detection\_continuous.py still uses prts as a dependency. What should be done with that?

The functions in _continuous.py can use the new implementation within aeon.

This should be everything?

Could you add this information to the corresponding issue? This should be addressed in separate PRs.

@aryanpola
Copy link
Contributor Author

@MatthewMiddlehurst @SebastianSchmidl Further changes to be made:

  1. Remove prts from all_extras
  2. Update tests to compare the implementation output with hard-coded values (already done in previous commits).
  3. Remove the older function, which includes aeon\benchmarking\metrics\anomaly_detection\_binary.py. aeon\benchmarking\metrics\anomaly_detection\_continuous.py still uses prts as a dependency. What should be done with that?

The functions in _continuous.py can use the new implementation within aeon.

This should be everything?

Could you add this information to the corresponding issue? This should be addressed in separate PRs.

3 different PR's for 3 mentioned changes?

@aryanpola
Copy link
Contributor Author

@MatthewMiddlehurst Please merge this PR so I can pull the changes and update the test cases to hard-coded ones.

@aryanpola
Copy link
Contributor Author

aryanpola commented Feb 28, 2025

@MatthewMiddlehurst Please merge this PR so I can pull the changes and update the test cases to hard-coded ones.

@MatthewMiddlehurst A gentle reminder.

@aryanpola
Copy link
Contributor Author

aryanpola commented Mar 19, 2025

@MatthewMiddlehurst @SebastianSchmidl Anything else to do here?
I tried creating a new PR with a branch within recall branch, this brings all the previous commits from recall branch creating conflicts. I'll update the test cases once this gets merged.

@MatthewMiddlehurst MatthewMiddlehurst merged commit de52e1d into aeon-toolkit:main Mar 21, 2025
18 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
anomaly detection Anomaly detection package benchmarking Benchmarking package enhancement New feature, improvement request or other non-bug code enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants