(results: EvalResult[], gate: EvalGate = 0.7)
| 140 | } |
| 141 | |
| 142 | export function summarizeEvaluation(results: EvalResult[], gate: EvalGate = 0.7): EvalSummary { |
| 143 | const total = results.length; |
| 144 | const top1Correct = results.filter((result) => result.top1Correct).length; |
| 145 | const top3RecallCount = results.filter((result) => result.top3Recall).length; |
| 146 | const specContaminatedCount = results.filter((result) => result.specContaminated).length; |
| 147 | const avgTopScore = |
| 148 | total > 0 ? results.reduce((sum, result) => sum + result.score, 0) / total : 0; |
| 149 | const gateThreshold = resolveGateThreshold(total, gate); |
| 150 | |
| 151 | return { |
| 152 | total, |
| 153 | top1Correct, |
| 154 | top1Accuracy: total > 0 ? top1Correct / total : 0, |
| 155 | top3RecallCount, |
| 156 | top3Recall: total > 0 ? top3RecallCount / total : 0, |
| 157 | specContaminatedCount, |
| 158 | specContaminationRate: total > 0 ? specContaminatedCount / total : 0, |
| 159 | avgTopScore, |
| 160 | gateThreshold, |
| 161 | passesGate: total > 0 && top1Correct >= gateThreshold, |
| 162 | results |
| 163 | }; |
| 164 | } |
| 165 | |
| 166 | export function formatEvalReport({ |
| 167 | codebaseLabel, |
no test coverage detected