LagsAdder#
- class openstef_models.transforms.time_domain.lags_adder.LagsAdder(**data: Any) None[source]
Bases:
BaseConfig,TimeSeriesTransformTransform that adds lag features to time series data.
Creates lagged copies of the target variable to capture temporal dependencies. Handles both single-horizon and multi-horizon (versioned) datasets, ensuring lags are valid for each forecast horizon.
Invariants
fit() must be called before transform() when add_autocorr_lags=True
Lags are only added if they fall within the available history window
For each horizon, only lags >= horizon are included (prevents data leakage)
All lag features use consistent naming: {target_column}_lag_{duration}
- Parameters:
data (
Any)
-
history_available:
timedelta
-
target_column:
str
-
max_day_lags:
int
-
add_trivial_lags:
bool
-
add_autocorr_lags:
bool
- property horizon_lags: dict[LeadTime, list[timedelta]]
Mapping of forecast horizons to their valid lag features.
- property min_horizon: timedelta
Shortest forecast horizon to determine minimum lag requirements.
- model_post_init(context: Any) None[source]
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- property is_fitted: bool
Check if the transform has been fitted.
- fit(data: TimeSeriesDataset) None[source]
Fit the transform to the input data.
This method should be called before applying the transform to the data. It allows the transform to learn any necessary parameters from the data.
- Parameters:
data (
TimeSeriesDataset) – The input data to fit the transform on.data
- Return type:
- transform(data: TimeSeriesDataset) TimeSeriesDataset[source]
Transform the input data.
This method should apply a transformation to the input data and return a new instance.
- Parameters:
data (
TimeSeriesDataset) – The input data to be transformed.data
- Returns:
A new instance of the transformed data.
- Raises:
NotFittedError – If the transform has not been fitted yet.
- Return type:
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].