openstef 3.4.16__py3-none-any.whl → 3.4.17__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.
@@ -16,6 +16,7 @@ from openstef.model.serializer import MLflowSerializer
16
16
  from openstef.pipeline.utils import generate_forecast_datetime_range
17
17
  from openstef.postprocessing.postprocessing import (
18
18
  add_prediction_job_properties_to_forecast,
19
+ sort_quantiles,
19
20
  )
20
21
  from openstef.validation import validation
21
22
 
@@ -149,6 +150,9 @@ def create_forecast_pipeline_core(
149
150
  model, forecast_input_data
150
151
  ).add_confidence_interval(forecast, pj)
151
152
 
153
+ # Sort quantiles - prevents crossing and is statistically sound
154
+ forecast = sort_quantiles(forecast)
155
+
152
156
  # Prepare for output
153
157
  forecast = add_prediction_job_properties_to_forecast(
154
158
  pj,
@@ -244,3 +244,25 @@ def add_prediction_job_properties_to_forecast(
244
244
  forecast["algtype"] = algorithm_type
245
245
 
246
246
  return forecast
247
+
248
+
249
+ def sort_quantiles(
250
+ forecast: pd.DataFrame, quantile_col_start="quantile_P"
251
+ ) -> pd.DataFrame:
252
+ """Sort quantile values so quantiles do not cross.
253
+
254
+ This function assumes that all quantile columns start with 'quantile_P'
255
+ For more academic details on why this is mathematically sounds,
256
+ please refer to Quantile and Probability Curves Without Crossing (Chernozhukov, 2010)
257
+ """
258
+ p_columns = [col for col in forecast.columns if col.startswith(quantile_col_start)]
259
+
260
+ if len(p_columns) == 0:
261
+ return forecast
262
+
263
+ # sort the columns
264
+ p_columns = np.sort(p_columns)
265
+
266
+ forecast.loc[:, p_columns] = forecast[p_columns].apply(sorted, axis=1).to_list()
267
+
268
+ return forecast
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openstef
3
- Version: 3.4.16
3
+ Version: 3.4.17
4
4
  Summary: Open short term energy forecaster
5
5
  Home-page: https://github.com/OpenSTEF/openstef
6
6
  Author: Alliander N.V
@@ -71,13 +71,13 @@ openstef/monitoring/teams.py,sha256=fnZScPD55z9yC0q3YavWj40GEZmL7tsSGhWzG_sMPws,
71
71
  openstef/pipeline/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
72
72
  openstef/pipeline/create_basecase_forecast.py,sha256=osrAlPjveM_fK0TEyVaA6rtqdn-jd1dV7fxU5c3-Muo,4414
73
73
  openstef/pipeline/create_component_forecast.py,sha256=qrIfpCNeoHgSddlzG_-XMHfBmSMclGoOkW-jH35ugkk,6254
74
- openstef/pipeline/create_forecast.py,sha256=bE1gTSP-HAjFSt-Xdoiy5BxDIo7lYq-Z-gvU7zFrRfw,5350
74
+ openstef/pipeline/create_forecast.py,sha256=RPoPJV4CEM29EAQRoWqbkIejxuHk1sbMLr4XhHQ2zlk,5479
75
75
  openstef/pipeline/optimize_hyperparameters.py,sha256=dG2GMTwxb5lHBit_xRgVabcC-PHbifccoPgl9nL-1Xk,10836
76
76
  openstef/pipeline/train_create_forecast_backtest.py,sha256=7uNeY8dKtJLha_LkwroyU76oB54R9p3zRlTJAJj4OoI,6048
77
77
  openstef/pipeline/train_model.py,sha256=LWvqANH8fpo8blwQ8Rgc1Z7EXvmZC0vTYwaOvSbr7qM,19496
78
78
  openstef/pipeline/utils.py,sha256=23mB31p19FoGWelLJzxNmqlzGwEr3fCDBEA37V2kpYY,2167
79
79
  openstef/postprocessing/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
80
- openstef/postprocessing/postprocessing.py,sha256=nehd0tDpkdIaWFJggQ-fDizIKdfmqJ3IOGfk0sDnrzk,8409
80
+ openstef/postprocessing/postprocessing.py,sha256=4rSLsau-COGg3Eu4I0N-PaSOvvKCdnxyXTe3loWEv4U,9115
81
81
  openstef/preprocessing/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
82
82
  openstef/preprocessing/preprocessing.py,sha256=bM_cSSSb2vGTD79RGzUrI6KoELbzlCyJwc7jqQGNEsE,1454
83
83
  openstef/tasks/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
@@ -96,8 +96,8 @@ openstef/tasks/utils/predictionjobloop.py,sha256=Ysy3zF5lzPMz_asYDKeF5m0qgVT3tCt
96
96
  openstef/tasks/utils/taskcontext.py,sha256=yI6TntOkZcW8JiNVuw4uJIigEBL0_iIrkPklF4ZeCX4,5401
97
97
  openstef/validation/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
98
98
  openstef/validation/validation.py,sha256=F2tMG8T4sxl3-3zVzshgbBd5xVi7ERmKuqfPVAUp9p0,10445
99
- openstef-3.4.16.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
100
- openstef-3.4.16.dist-info/METADATA,sha256=tjLeznPeOd1mRLGirVr8ou6G6s-6TrX62BQ3xMKGPJ4,8125
101
- openstef-3.4.16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
102
- openstef-3.4.16.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
103
- openstef-3.4.16.dist-info/RECORD,,
99
+ openstef-3.4.17.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
100
+ openstef-3.4.17.dist-info/METADATA,sha256=OE5CsMOpmU-UL0wCWMlZLc5w-J1ehWN20wMy8q3uZCI,8125
101
+ openstef-3.4.17.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
102
+ openstef-3.4.17.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
103
+ openstef-3.4.17.dist-info/RECORD,,