def _normalize()

in src/dfcx_scrapi/tools/metrics.py [0:0]


    def _normalize(scores: dict[str, float]) -> dict[str, float]:
        """Create probability distribution-like normalization of the scores."""
        result = {key: 0 for key in scores}

        exp_scores = {}
        norm = 0
        for key, value in scores.items():
            if value is not None:
                exp_value = math.exp(value)
                exp_scores[key] = exp_value
                norm += exp_value

        if not exp_scores:
            return result

        for key, value in exp_scores.items():
            result[key] = value / norm
        return result