tweaked the minimum reward
Browse files- graders/grader_classification.py +14 -5
- graders/grader_detection.py +13 -5
- graders/grader_fix.py +13 -5
- server/fin_auditor_environment.py +14 -11
graders/grader_classification.py
CHANGED
|
@@ -20,15 +20,24 @@ class MediumClassificationGrader:
|
|
| 20 |
fn = float(getattr(state, "total_fn", 0))
|
| 21 |
|
| 22 |
total = tp + tn + fp + fn
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
positive_signal = (tp * _TP_WEIGHT) + (tn * _TN_WEIGHT)
|
| 27 |
negative_signal = (fp * _FP_PENALTY) + (fn * _FN_PENALTY)
|
| 28 |
|
| 29 |
-
|
| 30 |
-
raw_score = max(0.0, positive_signal - negative_signal) /
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
self.last_breakdown = {"tp": int(tp), "tn": int(tn), "fp": int(fp), "fn": int(fn), "score": score}
|
| 34 |
return score
|
|
|
|
| 20 |
fn = float(getattr(state, "total_fn", 0))
|
| 21 |
|
| 22 |
total = tp + tn + fp + fn
|
| 23 |
+
|
| 24 |
+
# The maximum possible score if they made zero mistakes
|
| 25 |
+
actual_anomalies = tp + fn
|
| 26 |
+
actual_valid = tn + fp
|
| 27 |
+
|
| 28 |
+
perfect_signal = (actual_anomalies * _TP_WEIGHT) + (actual_valid * _TN_WEIGHT)
|
| 29 |
+
|
| 30 |
+
if perfect_signal == 0:
|
| 31 |
+
return 0.1
|
| 32 |
|
| 33 |
positive_signal = (tp * _TP_WEIGHT) + (tn * _TN_WEIGHT)
|
| 34 |
negative_signal = (fp * _FP_PENALTY) + (fn * _FN_PENALTY)
|
| 35 |
|
| 36 |
+
# Normalize against the true perfect scenario
|
| 37 |
+
raw_score = max(0.0, positive_signal - negative_signal) / perfect_signal
|
| 38 |
|
| 39 |
+
# Strict hackathon boundary
|
| 40 |
+
score = max(0.1, min(0.99, raw_score))
|
| 41 |
+
|
| 42 |
self.last_breakdown = {"tp": int(tp), "tn": int(tn), "fp": int(fp), "fn": int(fn), "score": score}
|
| 43 |
return score
|
graders/grader_detection.py
CHANGED
|
@@ -20,15 +20,23 @@ class EasyDetectionGrader:
|
|
| 20 |
fn = float(getattr(state, "total_fn", 0))
|
| 21 |
|
| 22 |
total = tp + tn + fp + fn
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
positive_signal = (tp * _TP_WEIGHT) + (tn * _TN_WEIGHT)
|
| 27 |
negative_signal = (fp * _FP_PENALTY) + (fn * _FN_PENALTY)
|
| 28 |
|
| 29 |
-
|
| 30 |
-
raw_score = max(0.0, positive_signal - negative_signal) /
|
| 31 |
|
| 32 |
-
|
|
|
|
| 33 |
self.last_breakdown = {"tp": int(tp), "tn": int(tn), "fp": int(fp), "fn": int(fn), "score": score}
|
| 34 |
return score
|
|
|
|
| 20 |
fn = float(getattr(state, "total_fn", 0))
|
| 21 |
|
| 22 |
total = tp + tn + fp + fn
|
| 23 |
+
|
| 24 |
+
# The maximum possible score if they made zero mistakes
|
| 25 |
+
actual_anomalies = tp + fn
|
| 26 |
+
actual_valid = tn + fp
|
| 27 |
+
|
| 28 |
+
perfect_signal = (actual_anomalies * _TP_WEIGHT) + (actual_valid * _TN_WEIGHT)
|
| 29 |
+
|
| 30 |
+
if perfect_signal == 0:
|
| 31 |
+
return 0.1
|
| 32 |
|
| 33 |
positive_signal = (tp * _TP_WEIGHT) + (tn * _TN_WEIGHT)
|
| 34 |
negative_signal = (fp * _FP_PENALTY) + (fn * _FN_PENALTY)
|
| 35 |
|
| 36 |
+
# Normalize against the true perfect scenario
|
| 37 |
+
raw_score = max(0.0, positive_signal - negative_signal) / perfect_signal
|
| 38 |
|
| 39 |
+
# Strict hackathon boundary
|
| 40 |
+
score = max(0.1, min(0.99, raw_score))
|
| 41 |
self.last_breakdown = {"tp": int(tp), "tn": int(tn), "fp": int(fp), "fn": int(fn), "score": score}
|
| 42 |
return score
|
graders/grader_fix.py
CHANGED
|
@@ -20,15 +20,23 @@ class HardFixGrader:
|
|
| 20 |
fn = float(getattr(state, "total_fn", 0))
|
| 21 |
|
| 22 |
total = tp + tn + fp + fn
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
positive_signal = (tp * _TP_WEIGHT) + (tn * _TN_WEIGHT)
|
| 27 |
negative_signal = (fp * _FP_PENALTY) + (fn * _FN_PENALTY)
|
| 28 |
|
| 29 |
-
|
| 30 |
-
raw_score = max(0.0, positive_signal - negative_signal) /
|
| 31 |
|
| 32 |
-
|
|
|
|
| 33 |
self.last_breakdown = {"tp": int(tp), "tn": int(tn), "fp": int(fp), "fn": int(fn), "score": score}
|
| 34 |
return score
|
|
|
|
| 20 |
fn = float(getattr(state, "total_fn", 0))
|
| 21 |
|
| 22 |
total = tp + tn + fp + fn
|
| 23 |
+
|
| 24 |
+
# The maximum possible score if they made zero mistakes
|
| 25 |
+
actual_anomalies = tp + fn
|
| 26 |
+
actual_valid = tn + fp
|
| 27 |
+
|
| 28 |
+
perfect_signal = (actual_anomalies * _TP_WEIGHT) + (actual_valid * _TN_WEIGHT)
|
| 29 |
+
|
| 30 |
+
if perfect_signal == 0:
|
| 31 |
+
return 0.1
|
| 32 |
|
| 33 |
positive_signal = (tp * _TP_WEIGHT) + (tn * _TN_WEIGHT)
|
| 34 |
negative_signal = (fp * _FP_PENALTY) + (fn * _FN_PENALTY)
|
| 35 |
|
| 36 |
+
# Normalize against the true perfect scenario
|
| 37 |
+
raw_score = max(0.0, positive_signal - negative_signal) / perfect_signal
|
| 38 |
|
| 39 |
+
# Strict hackathon boundary
|
| 40 |
+
score = max(0.1, min(0.99, raw_score))
|
| 41 |
self.last_breakdown = {"tp": int(tp), "tn": int(tn), "fp": int(fp), "fn": int(fn), "score": score}
|
| 42 |
return score
|
server/fin_auditor_environment.py
CHANGED
|
@@ -170,22 +170,25 @@ class FinAuditorEnvironment(Environment):
|
|
| 170 |
anomalies: list[list[float]] = self.engine.get_anomaly_matrix().tolist()
|
| 171 |
done = self._state.step_count >= self._MAX_EPISODE_STEPS
|
| 172 |
|
| 173 |
-
# 4. COMPUTE LIVE STEP REWARD
|
| 174 |
-
# Uses same asymmetric weights as FinAuditorGrader so the dashboard
|
| 175 |
-
# value is consistent with the official final episode score.
|
| 176 |
tp = float(self._state.total_tp)
|
| 177 |
tn = float(self._state.total_tn)
|
| 178 |
fp = float(self._state.total_fp)
|
| 179 |
fn = float(self._state.total_fn)
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
else:
|
| 188 |
-
|
|
|
|
| 189 |
|
| 190 |
return FinAuditorObservation(
|
| 191 |
features=anomalies,
|
|
|
|
| 170 |
anomalies: list[list[float]] = self.engine.get_anomaly_matrix().tolist()
|
| 171 |
done = self._state.step_count >= self._MAX_EPISODE_STEPS
|
| 172 |
|
| 173 |
+
# 4. COMPUTE LIVE STEP REWARD
|
|
|
|
|
|
|
| 174 |
tp = float(self._state.total_tp)
|
| 175 |
tn = float(self._state.total_tn)
|
| 176 |
fp = float(self._state.total_fp)
|
| 177 |
fn = float(self._state.total_fn)
|
| 178 |
+
|
| 179 |
+
actual_anomalies = tp + fn
|
| 180 |
+
actual_valid = tn + fp
|
| 181 |
+
perfect_signal = (actual_anomalies * 1.0) + (actual_valid * 0.1)
|
| 182 |
+
|
| 183 |
+
if perfect_signal > 0:
|
| 184 |
+
positive = (tp * 1.0) + (tn * 0.1)
|
| 185 |
+
negative = (fp * 0.1) + (fn * 0.4)
|
| 186 |
+
raw = max(0.0, positive - negative) / perfect_signal
|
| 187 |
+
# REDDIT FIX: Changed 0.01 to 0.1
|
| 188 |
+
step_reward = max(0.1, min(0.99, raw))
|
| 189 |
else:
|
| 190 |
+
# REDDIT FIX: Changed 0.01 to 0.1
|
| 191 |
+
step_reward = 0.1
|
| 192 |
|
| 193 |
return FinAuditorObservation(
|
| 194 |
features=anomalies,
|