Feature specs๏
Declarative feature specs, materialized point-in-time-correctly.
The most common accidental leak is feature engineering done on the full
frame โ lags and rolling means computed once over train+test. These specs are
instead materialized through the feedโs availability rules (see
emflow.features.materialize): a lag that would reach past the originโs
information set comes out NaN, never as a peeked value.
Four spec types (deliberately minimal):
Lagโ value of an actual field attarget_time - lagRollingโ trailing-window aggregate of an actual fieldโs available history at the originForecastFieldโ columns of the latest forecast run knowable at the origin, aligned to target timesCalendarโ deterministic calendar encodings of the target time
- class emflow.features.spec.Lag(field: str, lags: Tuple[str, ...], column: str | None = None)[source]๏
Bases:
objectfieldโs value attarget_time - lag, if knowable at the origin.- field: str๏
- lags: Tuple[str, ...]๏
- column: str | None = None๏
- class emflow.features.spec.Rolling(field: str, window: str, agg: str = 'mean', column: str | None = None)[source]๏
Bases:
objectTrailing-window
aggoffieldover the history available at the origin (same value for every target time of one origin).- field: str๏
- window: str๏
- agg: str = 'mean'๏
- column: str | None = None๏
- class emflow.features.spec.ForecastField(field: str, columns: Tuple[str, ...] = (), interp: str | None = None)[source]๏
Bases:
objectColumns of the latest run of forecast field
fieldknowable at the origin, looked up at each target time.interp="time"time-interpolates the run onto target times that fall between its native steps (e.g. hourly NWP onto half-hourly settlement periods). Interpolation only ever uses the already-knowable run โ it cannot leak.- field: str๏
- columns: Tuple[str, ...] = ()๏
- interp: str | None = None๏