Skip to content

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

Open
oglego wants to merge 2 commits intorust-ml:masterfrom
oglego:feature/add-smape-metric
Open

feat: add symmetric mean absolute percentage error (sMAPE)#437
oglego wants to merge 2 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 61.53846% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.70%. Comparing base (12c6c73) to head (18a622d).

Files with missing lines Patch % Lines
src/metrics_regression.rs 61.53% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #437      +/-   ##
==========================================
- Coverage   76.73%   76.70%   -0.03%     
==========================================
  Files         106      106              
  Lines        7410     7423      +13     
==========================================
+ Hits         5686     5694       +8     
- Misses       1724     1729       +5     

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

1 participant