coral-cyber commited on
Commit
bb92957
·
1 Parent(s): 12c7f22

fix(scoring): avoid boundary scores and adjust death penalty to 0.001

Browse files
environment/__pycache__/graders.cpython-314.pyc CHANGED
Binary files a/environment/__pycache__/graders.cpython-314.pyc and b/environment/__pycache__/graders.cpython-314.pyc differ
 
environment/graders.py CHANGED
@@ -18,11 +18,16 @@ from .models import GraderResult, PatientVitals
18
 
19
 
20
  def _lerp_score(value: float, worst: float, best: float) -> float:
21
- """Map a value linearly to [0, 1]. Clips to [0, 1]."""
22
  if best == worst:
23
  return 0.5
24
  s = (value - worst) / (best - worst)
25
- return max(0.0, min(1.0, s))
 
 
 
 
 
26
 
27
 
28
  def grade_mild_sepsis(
@@ -43,7 +48,7 @@ def grade_mild_sepsis(
43
  """
44
  if not alive or not trajectory:
45
  return GraderResult(
46
- score=0.0,
47
  reason="Patient died — episode score is 0.",
48
  metrics={"alive": 0.0},
49
  passed=False,
@@ -81,7 +86,7 @@ def grade_mild_sepsis(
81
  + 0.10 * wbc_score
82
  + 0.05 * speed_bonus
83
  )
84
- score = round(max(0.0, min(1.0, score)), 4)
85
 
86
  reason = (
87
  f"Patient alive. MAP={final.map_mmhg:.1f}, "
@@ -110,7 +115,7 @@ def grade_septic_shock(
110
  """
111
  if not alive or not trajectory:
112
  return GraderResult(
113
- score=0.0,
114
  reason="Patient died — episode score is 0.",
115
  metrics={"alive": 0.0},
116
  passed=False,
@@ -152,7 +157,7 @@ def grade_septic_shock(
152
  + 0.05 * vasopressor_score
153
  + 0.05 * speed_bonus
154
  )
155
- score = round(max(0.0, min(1.0, score)), 4)
156
 
157
  reason = (
158
  f"Patient alive. MAP={final.map_mmhg:.1f}, "
@@ -193,7 +198,7 @@ def grade_severe_mods(
193
  """
194
  if not alive or not trajectory:
195
  return GraderResult(
196
- score=0.0,
197
  reason="Patient died — episode score is 0.",
198
  metrics={"alive": 0.0},
199
  passed=False,
@@ -249,7 +254,7 @@ def grade_severe_mods(
249
  + 0.15 * renal_score
250
  + 0.10 * speed_bonus
251
  )
252
- score = round(max(0.0, min(1.0, score)), 4)
253
 
254
  reason = (
255
  f"Patient alive. MAP={final.map_mmhg:.1f}, "
 
18
 
19
 
20
  def _lerp_score(value: float, worst: float, best: float) -> float:
21
+ """Map a value linearly to (0, 1) — strictly exclusive."""
22
  if best == worst:
23
  return 0.5
24
  s = (value - worst) / (best - worst)
25
+ return max(0.001, min(0.999, s))
26
+
27
+
28
+ def _safe_score(score: float) -> float:
29
+ """Clamp final episode score to strictly (0, 1)."""
30
+ return round(max(0.001, min(0.999, score)), 4)
31
 
32
 
33
  def grade_mild_sepsis(
 
48
  """
49
  if not alive or not trajectory:
50
  return GraderResult(
51
+ score=0.001,
52
  reason="Patient died — episode score is 0.",
53
  metrics={"alive": 0.0},
54
  passed=False,
 
86
  + 0.10 * wbc_score
87
  + 0.05 * speed_bonus
88
  )
89
+ score = _safe_score(score)
90
 
91
  reason = (
92
  f"Patient alive. MAP={final.map_mmhg:.1f}, "
 
115
  """
116
  if not alive or not trajectory:
117
  return GraderResult(
118
+ score=0.001,
119
  reason="Patient died — episode score is 0.",
120
  metrics={"alive": 0.0},
121
  passed=False,
 
157
  + 0.05 * vasopressor_score
158
  + 0.05 * speed_bonus
159
  )
160
+ score = _safe_score(score)
161
 
162
  reason = (
163
  f"Patient alive. MAP={final.map_mmhg:.1f}, "
 
198
  """
199
  if not alive or not trajectory:
200
  return GraderResult(
201
+ score=0.001,
202
  reason="Patient died — episode score is 0.",
203
  metrics={"alive": 0.0},
204
  passed=False,
 
254
  + 0.15 * renal_score
255
  + 0.10 * speed_bonus
256
  )
257
+ score = _safe_score(score)
258
 
259
  reason = (
260
  f"Patient alive. MAP={final.map_mmhg:.1f}, "