Skip to content

feat(evaluate): verdict first, readable metrics, plain-language matrix and curves (#1168, #1171) - #1182

Merged
frankbria merged 1 commit into
mainfrom
fix/1168-evaluate-verdict
Nov 8, 2026
Merged

frankbria merged 1 commit into
mainfrom
fix/1168-evaluate-verdict

Conversation

@frankbria

Copy link
Copy Markdown
Owner

Closes #1168
Closes #1171

What

  • Loading and errors: a skeleton headed "Checking how well your model predicts" replaces the bare spinner. The error state offers Try again next to Go to Model Training.
  • Verdict first:
    • accuracy as a large percentage, with a one-line verdict;
    • whether the model beats always guessing the most common class;
    • "Mostly driven by …" naming the top three features.
    • Regression leads with R² as a percentage.
  • Metrics: shown as percentages, each with a short explanation. MAE and RMSE keep two decimals.
  • Confusion matrix:
    • a light theme ramp (primary for correct, destructive for wrong) with foreground text;
    • one sentence naming the worst-missed class, e.g. "Of 96 rows that really were '1', the model missed 42."
  • Class labels: the backend already returns the target's own class values. A target column that is itself 0/1 has no other word for its classes, so 0/1 stays.
  • ROC and PR curves: each has a one-sentence reading.
  • Code layout: app/evaluate/page.tsx is now a shell over components/evaluate/ (a useEvaluation hook plus small views). EvaluatePage was at complexity 30.

Tests

  • jest: new evaluationReading.test.ts; updated evaluate.page.test.tsx (loading, error and retry, verdict, metric text) and ConfusionMatrixChart.test.tsx.
  • Checks:
    • jest: 150 suites pass;
    • tsc clean; eslint at its cap; crap.sh passes;
    • chromium-smoke e2e: 45 passed, including evaluate.spec.ts.
  • Visual check: the loading skeleton and the confusion matrix with its reading on the real stack.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-08T22:02:08.003008Z
We couldn’t complete this review. Comment @codex review to try again.
18ede1d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Third Party Review — Codex

severity file:line finding failure scenario
P2 apps/frontend/components/evaluate/evaluationReading.ts:63 The verdict unconditionally claims evaluation used unseen rows, ignoring evaluation_on_calibration_set. Pass this flag into the verdict and qualify the statement when true. Small-data calibrated models are evaluated on the calibrator’s own fit data, and the backend explicitly flags these results as potentially optimistic. The new verdict incorrectly presents that accuracy as performance on unseen data.

VERDICT: DEFECTS

Model: Codex default

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Review of #1182: verdict-first Evaluate page

The refactor is clean. Splitting out evaluationReading.ts as pure functions and useEvaluation keeps the page easy to cover, and the new unit tests are good. I found no security concerns. The points below are mostly correctness edge cases in the plain-language copy.

Bugs / correctness

  • Negative R² gives a misleading verdict. regressionVerdict (evaluationReading.ts) uses percent(r2) for the headline and the sentence. A model worse than the mean (R² < 0) shows "-20% of the variation explained" and "Accounts for -20% of the ups and downs…". The baseline line then says "Always guessing the average would explain 0%", which contradicts it. Clamp the headline at 0, or add a "Worse than guessing the average" branch like the classification baseline has. Add a test for it.
  • confusionReading can pick a tiny class. It sorts by miss rate, so a class with 1 row and 1 miss (100%) beats a class with 500 rows and 200 misses, giving "Of 1 rows that really were…". Rank by miss count or require a minimum support. The "1 rows" plural also needs handling.
  • prReading uses only the first class. In multiclass it quotes the baseline of an arbitrary first key, Object.entries(...)[0]. Use the minority or positive class, or word the sentence generically when there is more than one class. rocReading calls a macro AUC "a true case above a false one", which is only exact for binary.
  • Empty paragraphs when a reading is null. ConfusionMatrixChart, ROCCurveChart and PRCurveChart always render <p>{reading}</p>, so a null reading leaves an empty <p> with mt-2/mt-3 margin. Render it conditionally, for example with the new when helper.
  • decimals loses precision for small-scale targets. MAE and RMSE use toFixed(2), so a target in the 0.001 range shows "0.00". Use significant digits, or scale the precision to the magnitude.
  • Brief "No Evaluation Data" state. evaluateView returns empty when there is no modelId and loading is false. The user sees the empty screen until the redirect effect fires. This behaviour existed before the PR, but the new useEvaluation is a good place to treat "no modelId" as loading.

Performance

  • loadEvaluation awaits the evaluation and only then starts the best-effort SHAP request. The new loading copy says "a few seconds", so a slow SHAP call now delays the whole page. Consider rendering as soon as the evaluation resolves and filling SHAP in afterwards. At minimum, start both requests together with Promise.all and the .catch(() => null) on the SHAP one.
  • "Try again" (reload) refetches both calls.

Style / conventions

  • ConfusionMatrixChart now uses fill="var(--primary)" and var(--destructive) as SVG attributes. Check that the theme tokens are full colour values rather than bare HSL triplets. Otherwise the cells render black, because jsdom tests cannot catch that.
  • The doc comment on ConfusionMatrixChart (lines ~18–24) now runs long, with an overlong line after the edit. Re-wrap it.
  • VerdictPanel uses key={line}, which would collide if two lines were identical. This is unlikely today.
  • A discriminated union for the view state would remove the as ReadyEvaluation and as string casts.

Tests

  • Missing cases: negative R², a tie or a tiny-support class in confusionReading, multiclass prReading, and a null reading not rendering an empty <p>.
  • No test covers the "Try again" button calling reload. It is new behaviour in EvaluateError.
  • Confirm that scripts/quality/crap.sh passes for buildVerdict, metricRows and confusionReading. All three have several branches.

@frankbria
frankbria merged commit 0b2a6a8 into main Nov 8, 2026
17 checks passed
@frankbria
frankbria deleted the fix/1168-evaluate-verdict branch November 8, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant