fix: handle test_ prefixed metric keys from training runs API

This commit is contained in:
Marko Djordjevic 2026-02-17 19:00:22 +01:00
parent 12a9603fce
commit a9bfe36e47
2 changed files with 9 additions and 5 deletions

View file

@ -20,6 +20,8 @@ interface TrainingRun {
metrics_summary?: {
accuracy?: number;
f1_macro?: number;
test_accuracy?: number;
test_f1_macro?: number;
[key: string]: number | undefined;
};
error?: string;
@ -304,11 +306,11 @@ export default function TrainingPanel() {
<div className="text-muted-foreground">{formatDate(run.created_at)}</div>
{run.status === 'completed' && run.metrics_summary && (
<div className="flex flex-wrap gap-x-2 text-muted-foreground">
{run.metrics_summary.accuracy !== undefined && (
<span>Acc: {(run.metrics_summary.accuracy * 100).toFixed(1)}%</span>
{(run.metrics_summary.accuracy ?? run.metrics_summary.test_accuracy) !== undefined && (
<span>Acc: {((run.metrics_summary.accuracy ?? run.metrics_summary.test_accuracy)! * 100).toFixed(1)}%</span>
)}
{run.metrics_summary.f1_macro !== undefined && (
<span>F1: {(run.metrics_summary.f1_macro * 100).toFixed(1)}%</span>
{(run.metrics_summary.f1_macro ?? run.metrics_summary.test_f1_macro) !== undefined && (
<span>F1: {((run.metrics_summary.f1_macro ?? run.metrics_summary.test_f1_macro)! * 100).toFixed(1)}%</span>
)}
</div>
)}