Spaces:
Running
Running
Sync from GitHub (tests passed)
Browse files
deep_learning/training/hyperopt.py
CHANGED
|
@@ -102,11 +102,10 @@ def _objective(trial, base_cfg: TFTASROConfig, master_data: tuple) -> float:
|
|
| 102 |
Composite objective (lower is better):
|
| 103 |
score = val_loss + variance_penalty
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
*capable* of higher VR; low VR indicates a bad config, not a fundamental limit.
|
| 110 |
"""
|
| 111 |
try:
|
| 112 |
import lightning.pytorch as pl
|
|
@@ -189,12 +188,17 @@ def _objective(trial, base_cfg: TFTASROConfig, master_data: tuple) -> float:
|
|
| 189 |
actual_std = float(y_actual[:n].std())
|
| 190 |
vr = pred_std / actual_std if actual_std > 1e-9 else 0.0
|
| 191 |
|
| 192 |
-
#
|
| 193 |
-
#
|
| 194 |
-
#
|
| 195 |
-
#
|
|
|
|
|
|
|
|
|
|
| 196 |
if vr < 0.5:
|
| 197 |
variance_penalty = 2.0 * (1.0 - vr / 0.5)
|
|
|
|
|
|
|
| 198 |
|
| 199 |
trial.set_user_attr("variance_ratio", round(vr, 4))
|
| 200 |
trial.set_user_attr("pred_std", round(pred_std, 6))
|
|
|
|
| 102 |
Composite objective (lower is better):
|
| 103 |
score = val_loss + variance_penalty
|
| 104 |
|
| 105 |
+
Two-sided variance penalty keeps predictions in a healthy amplitude zone:
|
| 106 |
+
VR < 0.5 β strong penalty (2.0Γ) β flat predictions are useless
|
| 107 |
+
0.5β1.5 β no penalty β wide healthy zone, not a narrow band
|
| 108 |
+
VR > 1.5 β gentle penalty (0.5Γ) β overconfident but still has signal
|
|
|
|
| 109 |
"""
|
| 110 |
try:
|
| 111 |
import lightning.pytorch as pl
|
|
|
|
| 188 |
actual_std = float(y_actual[:n].std())
|
| 189 |
vr = pred_std / actual_std if actual_std > 1e-9 else 0.0
|
| 190 |
|
| 191 |
+
# Two-sided penalty with a wide healthy zone [0.5, 1.5]:
|
| 192 |
+
# VR < 0.5 β strong penalty (flat predictions, the original problem)
|
| 193 |
+
# 0.5β1.5 β no penalty (3Γ wide zone, not a narrow band)
|
| 194 |
+
# VR > 1.5 β gentle penalty (overconfident, predictions louder than market)
|
| 195 |
+
#
|
| 196 |
+
# Asymmetric: too-flat is worse than too-loud (flat predictions are
|
| 197 |
+
# useless; loud predictions at least carry directional signal).
|
| 198 |
if vr < 0.5:
|
| 199 |
variance_penalty = 2.0 * (1.0 - vr / 0.5)
|
| 200 |
+
elif vr > 1.5:
|
| 201 |
+
variance_penalty = 0.5 * (vr - 1.5)
|
| 202 |
|
| 203 |
trial.set_user_attr("variance_ratio", round(vr, 4))
|
| 204 |
trial.set_user_attr("pred_std", round(pred_std, 6))
|