Print per-variant accuracy with bootstrap CIs, and pairwise comparisons.
(all_results: dict[str, dict[int, bool]])
| 68 | |
| 69 | |
| 70 | def print_results(all_results: dict[str, dict[int, bool]]): |
| 71 | """Print per-variant accuracy with bootstrap CIs, and pairwise comparisons.""" |
| 72 | rng = np.random.default_rng(BOOTSTRAP_SEED) |
| 73 | names = list(all_results.keys()) |
| 74 | |
| 75 | # Per-variant accuracy + CI |
| 76 | for name in names: |
| 77 | by_doc = all_results[name] |
| 78 | correct = sum(by_doc.values()) |
| 79 | total = len(by_doc) |
| 80 | arr = np.array(list(by_doc.values()), dtype=np.float64) |
| 81 | lo, hi = bootstrap_ci(arr, rng) |
| 82 | print( |
| 83 | f"{name}: {correct}/{total} correct ({100 * correct / total:.1f}%, 95% CI [{lo:.1f}%, {hi:.1f}%])" |
| 84 | ) |
| 85 | |
| 86 | # Pairwise paired bootstrap for each pair |
| 87 | if len(names) >= 2: |
| 88 | print() |
| 89 | for i in range(len(names)): |
| 90 | for j in range(i + 1, len(names)): |
| 91 | na, nb = names[i], names[j] |
| 92 | paired_bootstrap(all_results[na], all_results[nb], na, nb, rng) |
| 93 | |
| 94 | |
| 95 | def bootstrap_ci(arr: np.ndarray, rng: np.random.Generator) -> tuple[float, float]: |
no test coverage detected