Repository navigation
FEAT: Add compute_clustered_success_rate_ci for repeated objectives - #4832
Open
Seung-wa Akpan (seung-waedet) wants to merge 1 commit into
Open
Seung-wa Akpan (seung-waedet) wants to merge 1 commit into
Seung-wa Akpan (seung-waedet) wants to merge 1 commit into
Conversation
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
Contributor
There was a problem hiding this comment.
🟢 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
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.
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.pyrit/analytics/clustered_outcome_statistics.py, shaped likeoutcome_statistics.py. It takesoutcomes_by_cluster: Mapping[str, Sequence[AttackOutcome]]and returns a frozenClusteredSuccessRateIntervalwith the pooledstatisticsfromcompute_outcome_statistics,cluster_count,dropped_clusters,effective_sample_size, andclustered_ci_lower/clustered_ci_upper.compute_wilson_ciis unchanged.compute_wilson_ci's; when only one cluster has decided outcomes and it has several, they areNone.pyrit.analytics, with a short "Repeated objectives" section in the attack-result analytics guide that groups results byAttackResult.objective.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_wilsonon every row.Not included: ASSERT's z table,
macro_rate, suite wiring, andcompute_scenario_statisticswiring, which can follow now that #4652 madeselect_effective_attack_resultspublic.