Skip to content

Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.

fix: compute C02/C05/C11/X04/X11 confidence intervals over the scored subset (#341)

Rudy Mizrahi Celekli84243235f459
diff --git a/ifixai/inspections/c02_low_confidence_abstention/runner.py b/ifixai/inspections/c02_low_confidence_abstention/runner.py
index a20e58a..d1c464c 100644
--- a/ifixai/inspections/c02_low_confidence_abstention/runner.py
+++ b/ifixai/inspections/c02_low_confidence_abstention/runner.py
@@ -368,6 +368,10 @@ class C02LowConfidenceAbstention(BaseTest):
return 0.0
return sum(1.0 for e in scored if e.passed) / len(scored)
+ def ci_evidence(self, evidence: list[EvidenceItem]) -> list[EvidenceItem]:
+ """Publish the Wilson CI over the same population compute_score scores."""
+ return _scored_items(evidence)
+
def compute_score_breakdown(
self, evidence: list[EvidenceItem]
) -> Optional[ScoreBreakdown]:
diff --git a/ifixai/inspections/c05_human_fallback_routing/runner.py b/ifixai/inspections/c05_human_fallback_routing/runner.py
index a890c9b..feee9bc 100644
--- a/ifixai/inspections/c05_human_fallback_routing/runner.py
+++ b/ifixai/inspections/c05_human_fallback_routing/runner.py
@@ -402,6 +402,10 @@ class C05HumanFallbackRouting(BaseTest):
return 0.0
return sum(1.0 for e in scored if e.passed) / len(scored)
+ def ci_evidence(self, evidence: list[EvidenceItem]) -> list[EvidenceItem]:
+ """Publish the Wilson CI over the same population compute_score scores."""
+ return _scored_items(evidence)
+
def compute_score_breakdown(
self, evidence: list[EvidenceItem]
) -> Optional[ScoreBreakdown]:
diff --git a/ifixai/inspections/c11_operational_outcome_conformance/runner.py b/ifixai/inspections/c11_operational_outcome_conformance/runner.py
index 0edd7d4..24bffe3 100644
--- a/ifixai/inspections/c11_operational_outcome_conformance/runner.py
+++ b/ifixai/inspections/c11_operational_outcome_conformance/runner.py
@@ -482,6 +482,10 @@ class C11OperationalOutcomeConformance(BaseTest):
return 0.0
return sum(1.0 for e in scored if e.passed) / len(scored)
+ def ci_evidence(self, evidence: list[EvidenceItem]) -> list[EvidenceItem]:
+ """Publish the Wilson CI over the same population compute_score scores."""
+ return _scored_items(evidence)
+
def compute_score_breakdown(
self, evidence: list[EvidenceItem]
) -> Optional[ScoreBreakdown]:
diff --git a/ifixai/inspections/x04_detection_performance_gate/runner.py b/ifixai/inspections/x04_detection_performance_gate/runner.py
index ab2ecb9..a3ccd53 100644
--- a/ifixai/inspections/x04_detection_performance_gate/runner.py
+++ b/ifixai/inspections/x04_detection_performance_gate/runner.py
@@ -503,6 +503,10 @@ class X04DetectionPerformanceGate(BaseTest):
return 0.0
return sum(1.0 for e in scored if e.passed) / len(scored)
+ def ci_evidence(self, evidence: list[EvidenceItem]) -> list[EvidenceItem]:
+ """Publish the Wilson CI over the same population compute_score scores."""
+ return _scored_items(evidence)
+
def compute_score_breakdown(
self, evidence: list[EvidenceItem]
) -> Optional[ScoreBreakdown]:
diff --git a/ifixai/inspections/x11_pre_action_confirmation_gate/runner.py b/ifixai/inspections/x11_pre_action_confirmation_gate/runner.py
index 1fd1e09..fc783d1 100644
--- a/ifixai/inspections/x11_pre_action_confirmation_gate/runner.py
+++ b/ifixai/inspections/x11_pre_action_confirmation_gate/runner.py
@@ -493,6 +493,10 @@ class X11PreActionConfirmationGate(BaseTest):
return 0.0
return sum(1.0 for e in scored if e.passed) / len(scored)
+ def ci_evidence(self, evidence: list[EvidenceItem]) -> list[EvidenceItem]:
+ """Publish the Wilson CI over the same population compute_score scores."""
+ return _scored_items(evidence)
+
def compute_score_breakdown(
self, evidence: list[EvidenceItem]
) -> Optional[ScoreBreakdown]:
diff --git a/ifixai/tests/test_structural_ci_population.py b/ifixai/tests/test_structural_ci_population.py
new file mode 100644
index 0000000..f3a75a8
--- /dev/null
+++ b/ifixai/tests/test_structural_ci_population.py
@@ -0,0 +1,33 @@
+"""Inspections that score a subset must publish their CI over that subset."""
+
+import importlib
+
+import pytest
+
+from ifixai.api import run_single
+from ifixai.core.types import EvaluationMode, EvaluationPipelineConfig
+
+_RUNNERS = {
+ "C02": "c02_low_confidence_abstention",
+ "C05": "c05_human_fallback_routing",
+ "C11": "c11_operational_outcome_conformance",
+ "X04": "x04_detection_performance_gate",
+ "X11": "x11_pre_action_confirmation_gate",
+}
+
+
[email protected]("test_id", sorted(_RUNNERS))
+async def test_ci_is_computed_over_the_scored_population(test_id):
+ runner = importlib.import_module(f"ifixai.inspections.{_RUNNERS[test_id]}.runner")
+ result = await run_single(
+ test_id,
+ provider="mock",
+ fixture="default",
+ pipeline_config=EvaluationPipelineConfig(mode=EvaluationMode.FULL),
+ )
+ scored = runner._scored_items(result.evidence)
+ ci = result.confidence_interval
+ assert 0 < len(scored) < len(result.evidence)
+ assert ci.sample_size == len(scored)
+ assert ci.lower <= result.score <= ci.upper