openstef 3.4.54__py3-none-any.whl → 3.4.55__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ from pydantic.v1 import BaseModel
9
9
  from openstef.data_classes.data_prep import DataPrepDataClass
10
10
  from openstef.data_classes.model_specifications import ModelSpecificationDataClass
11
11
  from openstef.data_classes.split_function import SplitFuncDataClass
12
- from openstef.enums import PipelineType, BiddingZone
12
+ from openstef.enums import PipelineType, BiddingZone, AggregateFunction
13
13
 
14
14
 
15
15
  class PredictionJobDataClass(BaseModel):
@@ -83,6 +83,8 @@ class PredictionJobDataClass(BaseModel):
83
83
  data_balancing_ratio: Optional[float] = None
84
84
  """If data balancing is enabled, the data will be balanced with data from 1 year
85
85
  ago in the future."""
86
+ rolling_aggregate_features: Optional[list[AggregateFunction]] = None
87
+ """If not None, rolling aggregate(s) of load will be used as features in the model."""
86
88
  depends_on: Optional[list[Union[int, str]]]
87
89
  """Link to another prediction job on which this prediction job might depend."""
88
90
  sid: Optional[str]
openstef/enums.py CHANGED
@@ -108,6 +108,13 @@ class BiddingZone(Enum):
108
108
  DE_AMP_LU = "DE_AMP_LU"
109
109
 
110
110
 
111
+ class AggregateFunction(Enum):
112
+ MEAN = "mean"
113
+ MEDIAN = "median"
114
+ MAX = "max"
115
+ MIN = "min"
116
+
117
+
111
118
  class ModelType(Enum):
112
119
  XGB = "xgb"
113
120
  XGB_QUANTILE = "xgb_quantile"
@@ -22,6 +22,7 @@ from openstef.feature_engineering.lag_features import generate_lag_feature_funct
22
22
  from openstef.feature_engineering.bidding_zone_to_country_mapping import (
23
23
  BIDDING_ZONE_TO_COUNTRY_CODE_MAPPING,
24
24
  )
25
+ from openstef.feature_engineering.rolling_features import add_rolling_aggregate_features
25
26
  from openstef.feature_engineering.weather_features import (
26
27
  add_additional_solar_features,
27
28
  add_additional_wind_features,
@@ -130,5 +131,8 @@ def apply_features(
130
131
  # Adds daylight terrestrial feature
131
132
  data = add_daylight_terrestrial_feature(data)
132
133
 
134
+ if pj.get("rolling_aggregate_features") is not None:
135
+ data = add_rolling_aggregate_features(data, pj=pj)
136
+
133
137
  # Return dataframe including all requested features
134
138
  return data
@@ -0,0 +1,43 @@
1
+ # SPDX-FileCopyrightText: 2017-2023 Contributors to the OpenSTEF project <korte.termijn.prognoses@alliander.com> # noqa E501>
2
+ #
3
+ # SPDX-License-Identifier: MPL-2.0
4
+ from datetime import timedelta
5
+
6
+ import pandas as pd
7
+
8
+ from openstef.data_classes.prediction_job import PredictionJobDataClass
9
+
10
+
11
+ def add_rolling_aggregate_features(
12
+ data: pd.DataFrame,
13
+ pj: PredictionJobDataClass,
14
+ rolling_window: timedelta = timedelta(hours=24),
15
+ ) -> pd.DataFrame:
16
+ """
17
+ Adds rolling aggregate features to the input dataframe.
18
+
19
+ These features are calculated with an aggregation over a rolling window of the data.
20
+ A list of requested features is used to determine whether to add the rolling features
21
+ or not.
22
+
23
+ Args:
24
+ data: Input dataframe to which the rolling features will be added.
25
+ pj: Prediction job data.
26
+ rolling_window: Rolling window size for the aggregation.
27
+
28
+ Returns:
29
+ DataFrame with added rolling features.
30
+ """
31
+ # Ensure the index is a DatetimeIndex
32
+ if not isinstance(data.index, pd.DatetimeIndex):
33
+ raise ValueError("The DataFrame index must be a DatetimeIndex.")
34
+
35
+ if "load" not in data.columns:
36
+ raise ValueError("The DataFrame must contain a 'load' column.")
37
+ rolling_window_load = data["load"].rolling(window=rolling_window)
38
+
39
+ for aggregate_func in pj["rolling_aggregate_features"]:
40
+ data[
41
+ f"rolling_{aggregate_func.value}_load_{rolling_window}"
42
+ ] = rolling_window_load.aggregate(aggregate_func.value)
43
+ return data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: openstef
3
- Version: 3.4.54
3
+ Version: 3.4.55
4
4
  Summary: Open short term energy forecaster
5
5
  Home-page: https://github.com/OpenSTEF/openstef
6
6
  Author: Alliander N.V
@@ -1,7 +1,7 @@
1
1
  openstef/__init__.py,sha256=93UM6m0LLQhO69-mSqLuUy73jgs4W7Iuxfo3Lm8c98g,419
2
2
  openstef/__main__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
3
3
  openstef/app_settings.py,sha256=EJTDtimctFQQ-3f7ZcOQaRYohpZk3JD6aZBWPFYM2_A,582
4
- openstef/enums.py,sha256=wToJV56CAqgl-UY2DU1Zf12Ft9WsSiUNMrHYLnULOhQ,2724
4
+ openstef/enums.py,sha256=FrP0m_Tk0kV7gSZ2hTY_8iD45KIKnexHrjNufhpKXpE,2829
5
5
  openstef/exceptions.py,sha256=U4u2LTcdT6cmzpipT2Jh7kq9nCjT_-6gntn8yjuhGU0,1993
6
6
  openstef/settings.py,sha256=nSgkBqFxuqB3w7Rwo60i8j37c5ngDbt6vpjHS6QtJXQ,354
7
7
  openstef/data/NL_terrestrial_radiation.csv,sha256=A4kbW56GDzWi4tWUwY2C-4PiOvcKJCwkWQQtdg4ekPE,820246
@@ -17,10 +17,10 @@ openstef/data/dazls_model_3.4.24/dazls_stored_3.4.24_model_card.md.license,sha25
17
17
  openstef/data_classes/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
18
18
  openstef/data_classes/data_prep.py,sha256=gRSL7UiHvZis8m8z7VoTCZc0Ccffhef5_hmSyApnqK0,3417
19
19
  openstef/data_classes/model_specifications.py,sha256=Uod1W3QzhRqVLb6zvXwxh9wRL3EHCzSvX0oDNd28cFk,1197
20
- openstef/data_classes/prediction_job.py,sha256=hJNwLkCIIVsG5nzOmu_yY6rqTYzjuMt8FiLi7Aei3n4,5691
20
+ openstef/data_classes/prediction_job.py,sha256=OFGg6h0XQZOIkJEYr1EoT3LE2oV6YULaCCxhkaES4wA,5874
21
21
  openstef/data_classes/split_function.py,sha256=ljQIQQu1t1Y_CVWGAy25jrM6wG9odIVVQVimrT1n-1s,3358
22
22
  openstef/feature_engineering/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
23
- openstef/feature_engineering/apply_features.py,sha256=EIxP9fvmnAjFRehQpVGBhZHt35GACL-HhDm65_ktHc0,5121
23
+ openstef/feature_engineering/apply_features.py,sha256=9Yzg61Whd4n0osQBfrcW8cI0gaUiv7u8KnQIQPR40fY,5327
24
24
  openstef/feature_engineering/bidding_zone_to_country_mapping.py,sha256=u9aabjFDImydkO6_cXiaQxBT4gb5zy0gGTg2EoIUO_Y,2106
25
25
  openstef/feature_engineering/cyclic_features.py,sha256=0Z3wZeF_qrkmEcOq91gtdSMZucAq99kUoBuFDV0SHqk,5962
26
26
  openstef/feature_engineering/data_preparation.py,sha256=htca9LBO3ZN1D-iX4vXf0UN1fw_rRO7y6N3AuYVMpfk,5628
@@ -30,6 +30,7 @@ openstef/feature_engineering/general.py,sha256=tgU4_1stag9jJmaQAfWCMhfBscznVuQvW
30
30
  openstef/feature_engineering/holiday_features.py,sha256=CbolIP5bfiQkqDct-9TbD828-lhC48bfeNQ2-VFnsJA,8274
31
31
  openstef/feature_engineering/lag_features.py,sha256=Dr6qS8UhdgEHPZZSe-w6ibtjl_lcbcQohhqdZN9fqEU,5652
32
32
  openstef/feature_engineering/missing_values_transformer.py,sha256=o_zCVEOCPn2tWzvlY44XZuDysV0TuxqeVYhilYU54YY,5010
33
+ openstef/feature_engineering/rolling_features.py,sha256=596UWr0VIEgD2t5UhgPRjvOvcUI9v477M9yRaoYsnSk,1536
33
34
  openstef/feature_engineering/weather_features.py,sha256=Lr9DItyHvJ2CpWQ1r6A83tJKtR2k_Wwn32FdFTGblO0,15750
34
35
  openstef/metrics/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
35
36
  openstef/metrics/figure.py,sha256=KDoezYem9wdS13kUx7M7FOy-4u88Sg3OX1DuhNT6kgQ,9751
@@ -94,8 +95,8 @@ openstef/tasks/utils/predictionjobloop.py,sha256=Ysy3zF5lzPMz_asYDKeF5m0qgVT3tCt
94
95
  openstef/tasks/utils/taskcontext.py,sha256=L9K14ycwgVxbIVUjH2DIn_QWbnu-OfxcGtQ1K9T6sus,5630
95
96
  openstef/validation/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
96
97
  openstef/validation/validation.py,sha256=6FY-mD7bWxM7NpM9y-RcGZJt-kyyOmPl8QSemYRY11w,11200
97
- openstef-3.4.54.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
98
- openstef-3.4.54.dist-info/METADATA,sha256=AfvDSH_-juUUnXxlNW1Rvo-SZtujHl6YG6xcZ5VOSz8,8305
99
- openstef-3.4.54.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
100
- openstef-3.4.54.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
101
- openstef-3.4.54.dist-info/RECORD,,
98
+ openstef-3.4.55.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
99
+ openstef-3.4.55.dist-info/METADATA,sha256=c9Fc6xo3AyhI00vDWHrEzuFsCXfJbdPKAAgMRJ8DYcY,8305
100
+ openstef-3.4.55.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
101
+ openstef-3.4.55.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
102
+ openstef-3.4.55.dist-info/RECORD,,