Add generic data-fitting error metrics (MAE/L1, relative L2, Huber) to physicsnemo.metrics.general - #1807
Add generic data-fitting error metrics (MAE/L1, relative L2, Huber) to physicsnemo.metrics.general#1807wdyab wants to merge 1 commit into
Conversation
Greptile SummaryAdds three purely-additive data-fitting error metrics (
Important Files Changed
Reviews (2): Last reviewed commit: "Add general data-fitting error metrics t..." | Re-trigger Greptile |
Adds mae (mean absolute error, aliased as l1), relative_l2 / relative_lp (scale-invariant relative Lp error, a.k.a. LpLoss), and huber (smooth L1 error) to physicsnemo.metrics.general, complementing the existing mse / rmse. These are common regression losses used by neural-operator training loops and were previously missing from the library. Includes unit tests, API docs, and a CHANGELOG entry. Pre-commit: markdownlint and import-linter were skipped (SKIP=...) as they fail only on local environment artifacts (markdownlint's Node/npm cannot write to the sandbox tmp cache; import-linter reports pre-existing external-import violations with 0 file violations, which pass in upstream CI). ruff-check, ruff-format, interrogate, license header, and large-file hooks ran and passed; markdownlint content (88-char line length) was validated manually. Signed-off-by: wdyab <wdyab@nvidia.com>
38868b3 to
4d04a6d
Compare
|
@melo-gonzo for your review |
|
Both points are fair.
Closing this PR (and its issue #1804) accordingly. The two pieces from this stack that have no existing equivalent — Aside: the Greptile note about the Huber docstring is a false positive — |
Summary
Adds three commonly-needed data-fitting error metrics to the canonical
physicsnemo.metrics.general, complementing the existingmse/rmse:mae(mean absolute error), aliased asl1—physicsnemo/metrics/general/mae.pyrelative_l2and a generalrelative_lp(scale-invariant relative Lp error,a.k.a.
LpLoss) —physicsnemo/metrics/general/relative.pyhuber(smooth L1 error) —physicsnemo/metrics/general/huber.pyAll follow the existing functional
mse(pred, target, dim=None)signature style.An audit confirmed none of these existed anywhere in the library (only
mse/rmse),so this is purely additive with no duplication.
This is the first of three small, stacked PRs upstreaming reusable, generic
components discovered while developing a reservoir-simulation example.
Closes #1804
Test plan
test/metrics/test_metrics_general.pyextended with analytic value checks,zero-for-identical,
relative_l2scale-invariance, eps-guard, andper-dimension reduction tests.
interrogatedocstring coverage 100% on the new files.ruff check(E/F/S/I/PERF) andruff formatclean.