Selector#
- class openstef_models.transforms.general.Selector(**data: Any) None[source]
Bases:
BaseConfig,TimeSeriesTransformSelects features based on FeatureSelection.
Example
>>> import pandas as pd >>> from datetime import timedelta >>> from openstef_core.datasets import TimeSeriesDataset >>> from openstef_models.transforms.general import Selector >>> from openstef_models.utils.feature_selection import FeatureSelection >>> >>> # Create sample dataset >>> data = pd.DataFrame( ... { ... "load": [100.0, 110.0, 120.0], ... "temperature": [20.0, 22.0, 23.0], ... "humidity": [60.0, 65.0, 70.0], ... }, ... index=pd.date_range("2025-01-01", periods=3, freq="1h"), ... ) >>> dataset = TimeSeriesDataset(data, timedelta(hours=1)) >>> >>> # Select specific features >>> selector = Selector(selection=FeatureSelection(include={'load', 'temperature'})) >>> transformed = selector.transform(dataset) >>> transformed.feature_names ['load', 'temperature']
- Parameters:
data (
Any)
-
selection:
FeatureSelection
- 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].