@@ -63,8 +63,8 @@ def compute_delta(
6363 Returns (None, None) if either is missing or baseline value is zero.
6464
6565 Note: For error-rate metrics (WER — lower is better) a positive delta
66- means the WinML pipeline is *worse*. The threshold in derive_verdict()
67- uses abs(delta_relative) to handle both directions uniformly .
66+ means the WinML pipeline is *worse*. derive_verdict() normalizes the
67+ sign using higher_is_better from METRIC_COMPARE_STRATEGY .
6868 """
6969 if winml_metric is None or baseline_metric is None :
7070 return None , None
@@ -78,6 +78,24 @@ def compute_delta(
7878 return round (delta_abs , 6 ), round (delta_abs / base_val , 6 )
7979
8080
81+ def format_delta (accuracy : dict ) -> str :
82+ """Format the comparison delta as a display string using the metric strategy.
83+
84+ Returns e.g. ``"-6.0%"`` for relative metrics or ``"-1.27"`` for absolute.
85+ Returns ``""`` if delta is unavailable.
86+ """
87+ metric_name = (accuracy .get ("dataset_config" ) or {}).get ("metric" )
88+ delta_key = METRIC_COMPARE_STRATEGY .get (
89+ metric_name , METRIC_COMPARE_STRATEGY ["default" ]
90+ )[0 ]
91+ d = accuracy .get (delta_key )
92+ if d is None :
93+ return ""
94+ if delta_key == "delta_absolute" :
95+ return f"{ d :+.2f} "
96+ return f"{ d :.1%} "
97+
98+
8199# ---------------------------------------------------------------------------
82100# Verdict derivation (always from stored facts, never from a stored verdict)
83101# ---------------------------------------------------------------------------
@@ -214,10 +232,6 @@ def _val(acc: dict, key: str) -> str:
214232 v = (acc .get (key ) or {}).get ("value" )
215233 return f"{ v :.4f} " if isinstance (v , float ) else str (v ) if v is not None else "N/A"
216234
217- def _pct (acc : dict ) -> str :
218- d = acc .get ("delta_relative" )
219- return f"{ d :.1%} " if d is not None else "N/A"
220-
221235 lines = [
222236 "# Accuracy Evaluation Summary" ,
223237 "" ,
@@ -256,15 +270,15 @@ def _pct(acc: dict) -> str:
256270 lines += ["" , "## Accuracy Regressions" , "" ]
257271 if regressions :
258272 lines += [
259- "| Model | Task | WinML | Baseline | Delta% |" ,
260- "|-------|------|-----|----------|- -------|" ,
273+ "| Model | Task | WinML | Baseline | Delta |" ,
274+ "|-------|------|------- |----------|-------|" ,
261275 ]
262276 for r in regressions :
263277 acc = r ["accuracy" ]
264278 lines .append (
265279 f"| { r ['model' ]} | { r .get ('task' , '' )} "
266280 f"| { _val (acc , 'winml_metric' )} | { _val (acc , 'pytorch_baseline_metric' )} "
267- f"| { _pct (acc )} |"
281+ f"| { format_delta (acc )} |"
268282 )
269283 else :
270284 lines .append ("_No regressions._" )
@@ -277,15 +291,15 @@ def _pct(acc: dict) -> str:
277291 lines += ["" , "## At-Risk Models" , "" ]
278292 if at_risk :
279293 lines += [
280- "| Model | Task | WinML | Baseline | Delta% |" ,
281- "|-------|------|-----|----------|- -------|" ,
294+ "| Model | Task | WinML | Baseline | Delta |" ,
295+ "|-------|------|------- |----------|-------|" ,
282296 ]
283297 for r in at_risk :
284298 acc = r ["accuracy" ]
285299 lines .append (
286300 f"| { r ['model' ]} | { r .get ('task' , '' )} "
287301 f"| { _val (acc , 'winml_metric' )} | { _val (acc , 'pytorch_baseline_metric' )} "
288- f"| { _pct (acc )} |"
302+ f"| { format_delta (acc )} |"
289303 )
290304 else :
291305 lines .append ("_No at-risk models._" )
0 commit comments