File size: 237 Bytes
877add7
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
"""Calibration helpers."""

from __future__ import annotations


def calibrate_prob(prob: float, temperature: float = 1.0) -> float:
    if temperature <= 0:
        return prob
    return max(0.0, min(1.0, prob ** (1.0 / temperature)))