fix(evaluators): show honest Wilson CI when bootstrap degenerates at 0%/100% - #2034
Open
feiiiiii5 wants to merge 1 commit into
Open
fix(evaluators): show honest Wilson CI when bootstrap degenerates at 0%/100%#2034feiiiiii5 wants to merge 1 commit into
feiiiiii5 wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause
At a 0% or 100% pass rate,
calculate_bootstrap_ciresamples an identical population every iteration, sonp.percentilereturns a zero-width interval (e.g.[100.0, 100.0]). The evaluator then suppresses it becauseCI_DISPLAY_MIN_WIDTH = 0.001— the one case where the reader most needs an interval shows nothing at all.Fix
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 recordconfidence_method: "wilson"in the eval record.confidence_interval_method: "wilson"explicitly; the default remains"bootstrap"and non-degenerate bootstrap results are unchanged.Test
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 returnNone, 90% vs 95% width ordering, and the degenerate-fallback helper swaps only when the bootstrap interval is zero-width.test_bootstrap_ci,test_evaluators,test_ci_calculator(91 passed across the touched areas; 73 in the focused run).blackclean 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