Models¶
ForecastModel produces out-of-sample predictions used by detectors. The
validator combinators aggregate several models into a single decision.
Forecast model¶
signalflow.ForecastModel
dataclass
¶
ForecastModel(backend: object = 'lightgbm', target: Target | None = None, features: FeaturePipe | None = None, encode: WoE | None | str = _DEFAULT, select: object = _DEFAULT, sampler: Sampler | None = None, backend_params: dict = dict(), output: str = 'p_rise', n_folds: int = 5, min_train_rows: int = 50)
Trainable continuous predictor; outputs one probability column.
encode accepts a :class:WoE, None to disable encoding, or the
"default" sentinel that __post_init__ resolves to a default WoE.
Fitted encoders/selectors live on encode_/select_; the declarative
encode/select fields are never overwritten by fit.
dump_woe_history ¶
Serialize the refit timeline (binning + statistics) to portable JSON.
Source code in src/signalflow/model/forecast.py
fit ¶
Train the model and compute leak-free out-of-fold predictions.
Fits embargoed walk-forward folds (embargo width = the target horizon), stores
the stitched out-of-fold predictions on oos_, then fits the final production
stack on all data. When encode is a rolling WoE the folds follow its
refit/window; otherwise n_folds equal folds are used. Passing an
ArtifactCache reuses unchanged folds and recomputes only new ones.
Returns:
| Type | Description |
|---|---|
ForecastModel
|
The fitted model ( |
Source code in src/signalflow/model/forecast.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
operating_point ¶
operating_point(data: Dataset, quantile: float, column: str | None = None, oos: bool = False) -> float
Score quantile as a firing threshold; caller must pass train-window data for leak safety.
Source code in src/signalflow/model/forecast.py
predict ¶
Production prediction (in-sample on history - never feed to training).
Source code in src/signalflow/model/forecast.py
predict_oos ¶
Leak-free out-of-fold predictions over the training span.
With strict, rows outside the cached OOS span raise
:class:FingerprintMismatch instead of warning and returning nulls.
Source code in src/signalflow/model/forecast.py
woe_history ¶
Per-refit WoE state (bin edges + WoE table + IV) across the walk-forward.