| 10 | |
| 11 | @dataclass |
| 12 | class PlattCalibrator: |
| 13 | temperature: float = 1.0 |
| 14 | |
| 15 | def calibrate(self, raw_confidence: float) -> float: |
| 16 | safe = max(1e-6, min(1.0 - 1e-6, raw_confidence)) |
| 17 | logit = math.log(safe / (1.0 - safe)) |
| 18 | scaled = logit / max(0.05, self.temperature) |
| 19 | return 1.0 / (1.0 + math.exp(-scaled)) |
| 20 | |
| 21 | |
| 22 | def fit_platt_from_evals( |
no outgoing calls