Skip to content

FEAT: Add compute_clustered_success_rate_ci for repeated objectives - #4832

Open
Seung-wa Akpan (seung-waedet) wants to merge 1 commit into
microsoft:mainfrom
seung-waedet:feat/4707-clustered-success-rate-ci
Open

Seung-wa Akpan (seung-waedet) wants to merge 1 commit into
microsoft:mainfrom
seung-waedet:feat/4707-clustered-success-rate-ci

Conversation

@seung-waedet

Copy link
Copy Markdown
Contributor

Description

Adds compute_clustered_success_rate_ci, which gives the decided success rate a 95% interval that accounts for the same objective being attempted more than once. Fixes #4707.

  • New pyrit/analytics/clustered_outcome_statistics.py, shaped like outcome_statistics.py. It takes outcomes_by_cluster: Mapping[str, Sequence[AttackOutcome]] and returns a frozen ClusteredSuccessRateInterval with the pooled statistics from compute_outcome_statistics, cluster_count, dropped_clusters, effective_sample_size, and clustered_ci_lower / clustered_ci_upper.
  • Closed form from the issue: clustered variance with the C/(C-1) factor, effective sample size capped at n, and Wilson at that size with Student's t on C-1 degrees of freedom. The Wilson step is a private helper, so compute_wilson_ci is unchanged.
  • Only successes and failures count, and clusters with none are dropped and reported. When no cluster has more than one decided outcome the bounds are exactly compute_wilson_ci's; when only one cluster has decided outcomes and it has several, they are None.
  • Exported from pyrit.analytics, with a short "Repeated objectives" section in the attack-result analytics guide that groups results by AttackResult.objective.
  • The module docstring cites ASSERT's binary_rate_ci, Miller (2024) Appendix A Eq. 4, and Inspect AI's finite-cluster factor. No code is copied, so there is no notice entry.

Example: outcomes 2/3, 0/2 and 1/4 on three objectives give Wilson (0.121, 0.646) and clustered (0.038, 0.864), with an effective sample size of 54/7 instead of 9. On the issue's simulation script it gives the same coverage as clustered_wilson on every row.

Not included: ASSERT's z table, macro_rate, suite wiring, and compute_scenario_statistics wiring, which can follow now that #4652 made select_effective_attack_results public.

Add pyrit/analytics/clustered_outcome_statistics.py with
compute_clustered_success_rate_ci and ClusteredSuccessRateInterval. It
groups decided outcomes by cluster, usually one objective, and widens the
95% Wilson interval with the clustered variance of the pooled rate, an
effective sample size, and Student's t on C-1 degrees of freedom. When no
cluster has more than one decided outcome it returns compute_wilson_ci's
bounds; when only one cluster has decided outcomes and it has several,
the bounds are None.

Export it from pyrit.analytics and add a short section to the
attack-result analytics guide.

Fixes microsoft#4707
Copilot AI balanced review requested due to automatic review settings December 4, 2026 07:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the clustered confidence-interval changes.

No open issues 🎉

What changed in this PR

Adds clustered 95% confidence intervals for success rates when objectives repeat, addressing #4707 while preserving existing outcome statistics and Wilson behavior.

Changes:

  • Implements clustered variance, effective sample size, and Student’s t-adjusted Wilson bounds.
  • Exports the new API and documents grouping outcomes by objective.
  • Adds tests for formulas, exclusions, boundary cases, and Wilson compatibility.
File Description
tests/​unit/​analytics/​test_clustered_outcome_statistics.py Tests calculations and edge cases.
pyrit/​analytics/​clustered_outcome_statistics.py Implements clustered intervals and the frozen result dataclass.
pyrit/​analytics/​__init__.py Adds lazy public exports.
doc/​code/​analytics/​0_attack_results.md Documents repeated-objective analysis and usage.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

FEAT: Add compute_clustered_success_rate_ci analytics function (confidence interval for success rates when objectives repeat)

2 participants