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 at target_time - lag

  • Rolling โ€” trailing-window aggregate of an actual fieldโ€™s available history at the origin

  • ForecastField โ€” columns of the latest forecast run knowable at the origin, aligned to target times

  • Calendar โ€” deterministic calendar encodings of the target time

class emflow.features.spec.Lag(field: str, lags: Tuple[str, ...], column: str | None = None)[source]๏ƒ

Bases: object

fieldโ€™s value at target_time - lag, if knowable at the origin.

field: str๏ƒ
lags: Tuple[str, ...]๏ƒ
column: str | None = None๏ƒ
names()[source]๏ƒ
class emflow.features.spec.Rolling(field: str, window: str, agg: str = 'mean', column: str | None = None)[source]๏ƒ

Bases: object

Trailing-window agg of field over 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๏ƒ
names()[source]๏ƒ
class emflow.features.spec.ForecastField(field: str, columns: Tuple[str, ...] = (), interp: str | None = None)[source]๏ƒ

Bases: object

Columns of the latest run of forecast field field knowable 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๏ƒ
names()[source]๏ƒ
class emflow.features.spec.Calendar(parts: Tuple[str, ...] = ('hour', 'dayofweek'))[source]๏ƒ

Bases: object

Calendar encodings of the target time (leak-free by construction).

parts: Tuple[str, ...] = ('hour', 'dayofweek')๏ƒ
names()[source]๏ƒ