Skip to content

fix(evaluators): show honest Wilson CI when bootstrap degenerates at 0%/100% - #2034

Open
feiiiiii5 wants to merge 1 commit into
NVIDIA:mainfrom
feiiiiii5:fix/wilson-ci-degenerate-2033
Open

fix(evaluators): show honest Wilson CI when bootstrap degenerates at 0%/100%#2034
feiiiiii5 wants to merge 1 commit into
NVIDIA:mainfrom
feiiiiii5:fix/wilson-ci-degenerate-2033

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Root Cause

At a 0% or 100% pass rate, calculate_bootstrap_ci resamples an identical population every iteration, so np.percentile returns a zero-width interval (e.g. [100.0, 100.0]). The evaluator then suppresses it because CI_DISPLAY_MIN_WIDTH = 0.001 — the one case where the reader most needs an interval shows nothing at all.

Fix

  • Add garak/analyze/wilson_ci.py: a standard Wilson score interval (calculate_wilson_ci) plus a helper (fallback_wilson_if_degenerate) that swaps in Wilson only when the bootstrap interval is exactly degenerate.
  • evaluators/base.py: when bootstrap returns a zero-width CI (0%/100% observed rate), report the honest Wilson interval instead — e.g. 10/10 → [72%, 100%], 0/10 → [0%, 28%] at 95% — and record confidence_method: "wilson" in the eval record.
  • Also support confidence_interval_method: "wilson" explicitly; the default remains "bootstrap" and non-degenerate bootstrap results are unchanged.

Test

  • New tests/analyze/test_wilson_ci.py: boundary values match textbook Wilson intervals (10/10 → ~72.2–100, 0/10 → 0–~27.8), middle rates are within [0,100], invalid inputs return None, 90% vs 95% width ordering, and the degenerate-fallback helper swaps only when the bootstrap interval is zero-width.
  • Existing suites still pass: test_bootstrap_ci, test_evaluators, test_ci_calculator (91 passed across the touched areas; 73 in the focused run).
  • black clean on changed files.

Diff scope

3 files, +193/-3: garak/analyze/wilson_ci.py, garak/evaluators/base.py, tests/analyze/test_wilson_ci.py.

AI Disclosure

AI-assisted implementation and tests; human review of the Wilson interval math (verified against textbook values), the degenerate-detection semantics (exact zero-width only), method-recording in eval records, and final diff before submission.

Closes #2033

…0%/100%

A 0% or 100% pass rate makes every bootstrap resample identical, so the
percentile interval has zero width and the evaluator suppresses it
(CI_DISPLAY_MIN_WIDTH). That is the case where uncertainty matters most:
10/10 is compatible with a true rate around 90%, not exactly 100%.

Add a Wilson score interval helper and fall back to it whenever the
bootstrap interval is degenerate (all resamples identical), so the
report shows an honest interval instead of nothing. The explicit
confidence_interval_method='wilson' option is also supported; the
default remains 'bootstrap' and non-degenerate results are unchanged.

Signed-off-by: fei <204683769+feiiiiii5@users.noreply.github.com>
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.

Bootstrap CI degenerates to zero width at 0%/100% pass rates, so no interval is shown at all

1 participant