first (part 2: other directories)
Deploy Iddaai Backend / build-and-deploy (push) Failing after 18s

This commit is contained in:
2026-04-16 15:11:25 +03:00
parent 7814e0bc6b
commit 2f0b85a0c7
203 changed files with 59989 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
def calc_confidence_3way(top_prob: float) -> float:
"""Returns the true win probability percentage (e.g. 0.45 -> 45.0)."""
return max(0, min(99.0, top_prob * 100))
def calc_confidence_2way(prob: float) -> float:
"""Returns the true win probability percentage for the favored side."""
# Find the probability of the >0.5 side
win_prob = prob if prob >= 0.5 else (1.0 - prob)
return max(0, min(99.0, win_prob * 100))
def calc_confidence_dc(top_prob: float) -> float:
"""Returns the true win probability percentage for double chance."""
return max(0, min(99.0, top_prob * 100))
def calc_confidence_3way_with_agreement(top_prob: float, agreement_ratio: float,
boost: float = 1.05, penalty: float = 0.95) -> float:
"""
Returns the true win probability percentage, slightly adjusted by engine consensus.
Args:
top_prob: highest probability among options
agreement_ratio: 0.0 to 1.0 — how many engines agree on the pick
"""
base = calc_confidence_3way(top_prob)
# Slight nudge rather than massive swing, to keep it feeling like a true probability
if agreement_ratio >= 0.75:
return min(99.0, base * boost)
elif agreement_ratio <= 0.25:
return max(0.0, base * penalty)
return base