Skip to content

Conversation

@AnikethBhosale
Copy link

Description

Implements MSE (Mean Squared Error) metric for Pruna's evaluation framework. The metric computes mean squared error between model predictions and ground truth values, accumulating results across batches using StatefulMetric pattern.

Related Issue

Fixes #388

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Created comprehensive test suite with 15 tests covering:
    • Perfect match scenarios (MSE = 0)
    • Known value calculations
    • Multiple batch accumulation
    • Empty state handling
    • Multi-dimensional tensors (1D to 4D)
    • Device compatibility (CPU/CUDA)
    • Edge cases (None inputs, shape mismatches)
  • All tests pass: 14 passed, 1 skipped (CUDA test on non-CUDA systems)
  • Test coverage: 89% for metric_mse.py
  • Verified style compliance: ty check and ruff check pass

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

  • Metric is registered with MetricRegistry and can be used via Task(metrics=["mse"])
  • Follows existing patterns from other stateful metrics (e.g., SharpnessMetric)
  • Uses list-based state accumulation as required by StatefulMetric framework
  • Documentation includes usage examples, technical details, and related metrics

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 a simple MSE Metric

1 participant