Spaces:
Sleeping
Sleeping
Add Jared read-only token OHLCV ingestion and manual contract lookup
Browse files- core/train_eval.py +10 -1
core/train_eval.py
CHANGED
|
@@ -90,7 +90,16 @@ def inverse_target_scale(values, target_scaler):
|
|
| 90 |
"""Inverse-transform a single target feature for any batch/horizon shape."""
|
| 91 |
arr = np.asarray(values, dtype=float)
|
| 92 |
original_shape = arr.shape
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
return restored.reshape(original_shape)
|
| 95 |
|
| 96 |
# ---------------- Feature selection ----------------
|
|
|
|
| 90 |
"""Inverse-transform a single target feature for any batch/horizon shape."""
|
| 91 |
arr = np.asarray(values, dtype=float)
|
| 92 |
original_shape = arr.shape
|
| 93 |
+
flat = arr.reshape(-1, 1)
|
| 94 |
+
# Be defensive against an older/cached preprocessing path that fitted the
|
| 95 |
+
# target scaler with more than one column. Only the first target column is
|
| 96 |
+
# relevant; sklearn's multi-column inverse_transform would broadcast-fail.
|
| 97 |
+
if getattr(target_scaler, "n_features_in_", 1) != 1:
|
| 98 |
+
scale = float(np.asarray(target_scaler.scale_).reshape(-1)[0])
|
| 99 |
+
offset = float(np.asarray(target_scaler.min_).reshape(-1)[0])
|
| 100 |
+
restored = flat / scale + offset
|
| 101 |
+
else:
|
| 102 |
+
restored = target_scaler.inverse_transform(flat)
|
| 103 |
return restored.reshape(original_shape)
|
| 104 |
|
| 105 |
# ---------------- Feature selection ----------------
|