Skip to content

Conversation

@cmmartin
Copy link
Contributor

Fixes #323

Checklist

  • My branch is up-to-date with development branch.
  • Everything works and tested on latest stable Rust.
  • Coverage and Linting have been applied

Current behaviour

  • recall
    • binary case calculates precision instead of recall due to incorrect false negative counting
    • multiclass case computes accuracy (total correct / total) instead of macro-averaged recall
  • precision
    • binary case calculates recall instead of precision due to incorrect false positive counting
    • multiclass case computes accuracy instead of macro-averaged precision

New expected behaviour

  • recall
    • binary case correctly calculates recall
    • multiclass case computes macro-averaged recall instead of accuracy
    • handles zero-division edge case
  • precision
    • binary case correctly calculates precision
    • multiclass case computes macro-averaged precision instead of accuracy
    • handles zero-division edge case

Change logs

@cmmartin cmmartin requested a review from Mec-iS as a code owner November 22, 2025 03:46
@Mec-iS
Copy link
Collaborator

Mec-iS commented Nov 22, 2025

thanks a lot. I will review this on monday


let score3: f64 = Precision::new().get_score(&y_true, &y_pred);
assert!((score3 - 0.6666666666).abs() < 1e-8);
assert!((score3 - 0.5).abs() < 1e-8);
Copy link
Collaborator

Choose a reason for hiding this comment

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

it would be nice to take the opportunity and make these statements to use approx where possible

Copy link
Collaborator

@Mec-iS Mec-iS left a comment

Choose a reason for hiding this comment

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

💯
Hope you will stick around!

@Mec-iS
Copy link
Collaborator

Mec-iS commented Nov 24, 2025

I will merge this and create a new release

@Mec-iS Mec-iS closed this Nov 24, 2025
@Mec-iS Mec-iS reopened this Nov 24, 2025
@Mec-iS Mec-iS merged commit 70d8a0f into smartcorelib:development Nov 24, 2025
22 checks passed
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 51.42857% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.68%. Comparing base (9fef05e) to head (6db62f2).
⚠️ Report is 11 commits behind head on development.

Files with missing lines Patch % Lines
src/metrics/precision.rs 51.35% 18 Missing ⚠️
src/metrics/recall.rs 51.51% 16 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #338      +/-   ##
===============================================
+ Coverage        45.23%   45.68%   +0.44%     
===============================================
  Files               90       93       +3     
  Lines             7775     8034     +259     
===============================================
+ Hits              3517     3670     +153     
- Misses            4258     4364     +106     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Bug: Precision and recall calculations

2 participants