Skip to content

feat: add symmetric mean absolute percentage error (sMAPE)#437

Merged
relf merged 3 commits intorust-ml:masterfrom
oglego:feature/add-smape-metric
Apr 16, 2026
Merged

feat: add symmetric mean absolute percentage error (sMAPE)#437
relf merged 3 commits intorust-ml:masterfrom
oglego:feature/add-smape-metric

Conversation

@oglego
Copy link
Copy Markdown
Contributor

@oglego oglego commented Mar 29, 2026

Fixes #436

This PR adds the Symmetric Mean Absolute Percentage Error (sMAPE) metric.

sMAPE is a regression metric that addresses the asymmetry found in standard MAPE by normalizing the absolute error by the average of the actual and predicted values. This implementation is numerically stabilized with a small epsilon to handle cases where both the ground truth and prediction are zero.

Verified sMAPE testing with

cargo test metrics_regression

I tried to keep the formatting and style consistent with MAPE but if there is anything that needs to be changed just let me know!

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.76%. Comparing base (12c6c73) to head (248b841).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/metrics_regression.rs 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #437      +/-   ##
==========================================
+ Coverage   76.73%   76.76%   +0.03%     
==========================================
  Files         106      106              
  Lines        7410     7429      +19     
==========================================
+ Hits         5686     5703      +17     
- Misses       1724     1726       +2     

☔ 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.

Updated sMAPE formula to Adjusted (Makridakis, 1993) version

Changed output scaling to [0, 200]

Added test_symmetric_mean_absolute_percentage_error_multi_target
Copy link
Copy Markdown
Member

@relf relf left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution. After the minor fix below, it will be ok for me.

Comment thread src/metrics_regression.rs Outdated
Co-authored-by: Rémi Lafage <remi.lafage@onera.fr>
@oglego
Copy link
Copy Markdown
Contributor Author

oglego commented Apr 15, 2026

Thank you for reviewing this I really appreciate it! I've made the recommended change, thanks again!

@relf relf merged commit 1abc88f into rust-ml:master Apr 16, 2026
21 checks passed
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.

Feature: Add Symmetric Mean Absolute Percentage Error (sMAPE) to Regression Metrics

2 participants