openstef 3.4.19__py3-none-any.whl → 3.4.20__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.
- openstef/tasks/calculate_kpi.py +6 -4
 - openstef/tasks/create_basecase_forecast.py +8 -3
 - openstef/tasks/create_components_forecast.py +8 -3
 - openstef/tasks/create_forecast.py +5 -2
 - {openstef-3.4.19.dist-info → openstef-3.4.20.dist-info}/METADATA +1 -1
 - {openstef-3.4.19.dist-info → openstef-3.4.20.dist-info}/RECORD +9 -9
 - {openstef-3.4.19.dist-info → openstef-3.4.20.dist-info}/LICENSE +0 -0
 - {openstef-3.4.19.dist-info → openstef-3.4.20.dist-info}/WHEEL +0 -0
 - {openstef-3.4.19.dist-info → openstef-3.4.20.dist-info}/top_level.txt +0 -0
 
    
        openstef/tasks/calculate_kpi.py
    CHANGED
    
    | 
         @@ -72,6 +72,8 @@ def check_kpi_task( 
     | 
|
| 
       72 
72 
     | 
    
         
             
                context: TaskContext,
         
     | 
| 
       73 
73 
     | 
    
         
             
                start_time: datetime,
         
     | 
| 
       74 
74 
     | 
    
         
             
                end_time: datetime,
         
     | 
| 
      
 75 
     | 
    
         
            +
                threshold_optimizing=THRESHOLD_OPTIMIZING,
         
     | 
| 
      
 76 
     | 
    
         
            +
                threshold_retraining=THRESHOLD_RETRAINING,
         
     | 
| 
       75 
77 
     | 
    
         
             
            ) -> None:
         
     | 
| 
       76 
78 
     | 
    
         
             
                # Apply default parameters if none are provided
         
     | 
| 
       77 
79 
     | 
    
         
             
                if start_time is None:
         
     | 
| 
         @@ -102,20 +104,20 @@ def check_kpi_task( 
     | 
|
| 
       102 
104 
     | 
    
         | 
| 
       103 
105 
     | 
    
         
             
                # Add pid to the list of pids that should be retrained or optimized if
         
     | 
| 
       104 
106 
     | 
    
         
             
                # performance is insufficient
         
     | 
| 
       105 
     | 
    
         
            -
                if kpis["47.0h"]["rMAE"] >  
     | 
| 
      
 107 
     | 
    
         
            +
                if kpis["47.0h"]["rMAE"] > threshold_retraining:
         
     | 
| 
       106 
108 
     | 
    
         
             
                    context.logger.warning(
         
     | 
| 
       107 
109 
     | 
    
         
             
                        "Need to retrain model, retraining threshold rMAE 47h exceeded",
         
     | 
| 
       108 
110 
     | 
    
         
             
                        t_ahead="47.0h",
         
     | 
| 
       109 
111 
     | 
    
         
             
                        rMAE=kpis["47.0h"]["rMAE"],
         
     | 
| 
       110 
     | 
    
         
            -
                        retraining_threshold= 
     | 
| 
      
 112 
     | 
    
         
            +
                        retraining_threshold=threshold_retraining,
         
     | 
| 
       111 
113 
     | 
    
         
             
                    )
         
     | 
| 
       112 
114 
     | 
    
         | 
| 
       113 
     | 
    
         
            -
                if kpis["47.0h"]["rMAE"] >  
     | 
| 
      
 115 
     | 
    
         
            +
                if kpis["47.0h"]["rMAE"] > threshold_optimizing:
         
     | 
| 
       114 
116 
     | 
    
         
             
                    context.logger.warning(
         
     | 
| 
       115 
117 
     | 
    
         
             
                        "Need to optimize hyperparameters, optimizing threshold rMAE 47h exceeded",
         
     | 
| 
       116 
118 
     | 
    
         
             
                        t_ahead="47.0h",
         
     | 
| 
       117 
119 
     | 
    
         
             
                        rMAE=kpis["47.0h"]["rMAE"],
         
     | 
| 
       118 
     | 
    
         
            -
                        optimizing_threshold= 
     | 
| 
      
 120 
     | 
    
         
            +
                        optimizing_threshold=threshold_optimizing,
         
     | 
| 
       119 
121 
     | 
    
         
             
                    )
         
     | 
| 
       120 
122 
     | 
    
         | 
| 
       121 
123 
     | 
    
         | 
| 
         @@ -32,7 +32,10 @@ T_AHEAD_DAYS: int = 14 
     | 
|
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
            def create_basecase_forecast_task(
         
     | 
| 
       35 
     | 
    
         
            -
                pj: PredictionJobDataClass, 
     | 
| 
      
 35 
     | 
    
         
            +
                pj: PredictionJobDataClass,
         
     | 
| 
      
 36 
     | 
    
         
            +
                context: TaskContext,
         
     | 
| 
      
 37 
     | 
    
         
            +
                t_behind_days=T_BEHIND_DAYS,
         
     | 
| 
      
 38 
     | 
    
         
            +
                t_ahead_days=T_AHEAD_DAYS,
         
     | 
| 
       36 
39 
     | 
    
         
             
            ) -> None:
         
     | 
| 
       37 
40 
     | 
    
         
             
                """Top level task that creates a basecase forecast.
         
     | 
| 
       38 
41 
     | 
    
         | 
| 
         @@ -41,6 +44,8 @@ def create_basecase_forecast_task( 
     | 
|
| 
       41 
44 
     | 
    
         
             
                Args:
         
     | 
| 
       42 
45 
     | 
    
         
             
                    pj: Prediction job
         
     | 
| 
       43 
46 
     | 
    
         
             
                    context: Contect object that holds a config manager and a database connection
         
     | 
| 
      
 47 
     | 
    
         
            +
                    t_behind_days: number of days included as history. This is used to generated lagged features for the to-be-forecasted period
         
     | 
| 
      
 48 
     | 
    
         
            +
                    t_ahead_days: number of days a basecase forecast is created for
         
     | 
| 
       44 
49 
     | 
    
         | 
| 
       45 
50 
     | 
    
         
             
                """
         
     | 
| 
       46 
51 
     | 
    
         
             
                # Check pipeline types
         
     | 
| 
         @@ -63,8 +68,8 @@ def create_basecase_forecast_task( 
     | 
|
| 
       63 
68 
     | 
    
         
             
                    return
         
     | 
| 
       64 
69 
     | 
    
         | 
| 
       65 
70 
     | 
    
         
             
                # Define datetime range for input data
         
     | 
| 
       66 
     | 
    
         
            -
                datetime_start = datetime.utcnow() - timedelta(days= 
     | 
| 
       67 
     | 
    
         
            -
                datetime_end = datetime.utcnow() + timedelta(days= 
     | 
| 
      
 71 
     | 
    
         
            +
                datetime_start = datetime.utcnow() - timedelta(days=t_behind_days)
         
     | 
| 
      
 72 
     | 
    
         
            +
                datetime_end = datetime.utcnow() + timedelta(days=t_ahead_days)
         
     | 
| 
       68 
73 
     | 
    
         | 
| 
       69 
74 
     | 
    
         
             
                # Retrieve input data
         
     | 
| 
       70 
75 
     | 
    
         
             
                input_data = context.database.get_model_input(
         
     | 
| 
         @@ -43,7 +43,10 @@ T_AHEAD_DAYS = 3 
     | 
|
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
            def create_components_forecast_task(
         
     | 
| 
       46 
     | 
    
         
            -
                pj: PredictionJobDataClass, 
     | 
| 
      
 46 
     | 
    
         
            +
                pj: PredictionJobDataClass,
         
     | 
| 
      
 47 
     | 
    
         
            +
                context: TaskContext,
         
     | 
| 
      
 48 
     | 
    
         
            +
                t_behind_days: int = T_BEHIND_DAYS,
         
     | 
| 
      
 49 
     | 
    
         
            +
                t_ahead_days: int = T_AHEAD_DAYS,
         
     | 
| 
       47 
50 
     | 
    
         
             
            ) -> None:
         
     | 
| 
       48 
51 
     | 
    
         
             
                """Top level task that creates a components forecast.
         
     | 
| 
       49 
52 
     | 
    
         | 
| 
         @@ -52,6 +55,8 @@ def create_components_forecast_task( 
     | 
|
| 
       52 
55 
     | 
    
         
             
                Args:
         
     | 
| 
       53 
56 
     | 
    
         
             
                    pj: Prediction job
         
     | 
| 
       54 
57 
     | 
    
         
             
                    context: Contect object that holds a config manager and a database connection
         
     | 
| 
      
 58 
     | 
    
         
            +
                    t_behind_days: number of days in the past that the component forecast is created for
         
     | 
| 
      
 59 
     | 
    
         
            +
                    t_ahead_days: number of days in the future that the component forecast is created for
         
     | 
| 
       55 
60 
     | 
    
         | 
| 
       56 
61 
     | 
    
         
             
                Raises:
         
     | 
| 
       57 
62 
     | 
    
         
             
                    ComponentForecastTooShortHorizonError: If the forecast horizon is too short
         
     | 
| 
         @@ -71,8 +76,8 @@ def create_components_forecast_task( 
     | 
|
| 
       71 
76 
     | 
    
         
             
                    return
         
     | 
| 
       72 
77 
     | 
    
         | 
| 
       73 
78 
     | 
    
         
             
                # Define datetime range for input data
         
     | 
| 
       74 
     | 
    
         
            -
                datetime_start = datetime.utcnow() - timedelta(days= 
     | 
| 
       75 
     | 
    
         
            -
                datetime_end = datetime.utcnow() + timedelta(days= 
     | 
| 
      
 79 
     | 
    
         
            +
                datetime_start = datetime.utcnow() - timedelta(days=t_behind_days)
         
     | 
| 
      
 80 
     | 
    
         
            +
                datetime_end = datetime.utcnow() + timedelta(days=t_ahead_days)
         
     | 
| 
       76 
81 
     | 
    
         | 
| 
       77 
82 
     | 
    
         
             
                logger.info(
         
     | 
| 
       78 
83 
     | 
    
         
             
                    "Get predicted load", datetime_start=datetime_start, datetime_end=datetime_end
         
     | 
| 
         @@ -34,7 +34,9 @@ from openstef.validation.validation import detect_ongoing_zero_flatliner 
     | 
|
| 
       34 
34 
     | 
    
         
             
            T_BEHIND_DAYS: int = 14
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
            def create_forecast_task( 
     | 
| 
      
 37 
     | 
    
         
            +
            def create_forecast_task(
         
     | 
| 
      
 38 
     | 
    
         
            +
                pj: PredictionJobDataClass, context: TaskContext, t_behind_days: int = T_BEHIND_DAYS
         
     | 
| 
      
 39 
     | 
    
         
            +
            ) -> None:
         
     | 
| 
       38 
40 
     | 
    
         
             
                """Top level task that creates a forecast.
         
     | 
| 
       39 
41 
     | 
    
         | 
| 
       40 
42 
     | 
    
         
             
                On this task level all database and context manager dependencies are resolved.
         
     | 
| 
         @@ -45,6 +47,7 @@ def create_forecast_task(pj: PredictionJobDataClass, context: TaskContext) -> No 
     | 
|
| 
       45 
47 
     | 
    
         
             
                Args:
         
     | 
| 
       46 
48 
     | 
    
         
             
                    pj: Prediction job
         
     | 
| 
       47 
49 
     | 
    
         
             
                    context: Contect object that holds a config manager and a database connection
         
     | 
| 
      
 50 
     | 
    
         
            +
                    t_behind_days: number of days included as history. This is used to generated lagged features for the to-be-forecasted period
         
     | 
| 
       48 
51 
     | 
    
         | 
| 
       49 
52 
     | 
    
         
             
                """
         
     | 
| 
       50 
53 
     | 
    
         
             
                # Check pipeline types
         
     | 
| 
         @@ -70,7 +73,7 @@ def create_forecast_task(pj: PredictionJobDataClass, context: TaskContext) -> No 
     | 
|
| 
       70 
73 
     | 
    
         
             
                mlflow_tracking_uri = context.config.paths_mlflow_tracking_uri
         
     | 
| 
       71 
74 
     | 
    
         | 
| 
       72 
75 
     | 
    
         
             
                # Define datetime range for input data
         
     | 
| 
       73 
     | 
    
         
            -
                datetime_start = datetime.utcnow() - timedelta(days= 
     | 
| 
      
 76 
     | 
    
         
            +
                datetime_start = datetime.utcnow() - timedelta(days=t_behind_days)
         
     | 
| 
       74 
77 
     | 
    
         
             
                datetime_end = datetime.utcnow() + timedelta(seconds=pj.horizon_minutes * 60)
         
     | 
| 
       75 
78 
     | 
    
         | 
| 
       76 
79 
     | 
    
         
             
                # Retrieve input data
         
     | 
| 
         @@ -83,10 +83,10 @@ openstef/postprocessing/postprocessing.py,sha256=vJZ57TZ3MbG4c78P2cq8Sxs6VHl6kjF 
     | 
|
| 
       83 
83 
     | 
    
         
             
            openstef/preprocessing/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
         
     | 
| 
       84 
84 
     | 
    
         
             
            openstef/preprocessing/preprocessing.py,sha256=bM_cSSSb2vGTD79RGzUrI6KoELbzlCyJwc7jqQGNEsE,1454
         
     | 
| 
       85 
85 
     | 
    
         
             
            openstef/tasks/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
         
     | 
| 
       86 
     | 
    
         
            -
            openstef/tasks/calculate_kpi.py,sha256= 
     | 
| 
       87 
     | 
    
         
            -
            openstef/tasks/create_basecase_forecast.py,sha256= 
     | 
| 
       88 
     | 
    
         
            -
            openstef/tasks/create_components_forecast.py,sha256= 
     | 
| 
       89 
     | 
    
         
            -
            openstef/tasks/create_forecast.py,sha256= 
     | 
| 
      
 86 
     | 
    
         
            +
            openstef/tasks/calculate_kpi.py,sha256=78DuK30ohWIHuc6oneRXalcNMXQ5mzy2qDr9xsPdSQs,11882
         
     | 
| 
      
 87 
     | 
    
         
            +
            openstef/tasks/create_basecase_forecast.py,sha256=lxor1E3WQ_XAZDYWdNJKE1PY57scz39bKu2Id9U2GwE,4126
         
     | 
| 
      
 88 
     | 
    
         
            +
            openstef/tasks/create_components_forecast.py,sha256=j4m9AGjnMDx23FmsaZGPYn9rBMHsRd_h-m1RAfhF8to,6139
         
     | 
| 
      
 89 
     | 
    
         
            +
            openstef/tasks/create_forecast.py,sha256=NWd2fdbZ9CKDi190v7PF14IUdz6pyME2A-ssRNDdaYs,5750
         
     | 
| 
       90 
90 
     | 
    
         
             
            openstef/tasks/create_solar_forecast.py,sha256=bTr7NThTF6Yj405qAqRaJmlBUrL7HATqVVzsi9hMdMw,15049
         
     | 
| 
       91 
91 
     | 
    
         
             
            openstef/tasks/create_wind_forecast.py,sha256=RhshkmNSyFWx4Y6yQn02GzHjWTREbN5A5GAeWv0JpcE,2907
         
     | 
| 
       92 
92 
     | 
    
         
             
            openstef/tasks/optimize_hyperparameters.py,sha256=s-z8YQJF6Lf3DdYgKHEpAdlbFJ3a-0Gj0Ahsqj1DErc,4758
         
     | 
| 
         @@ -98,8 +98,8 @@ openstef/tasks/utils/predictionjobloop.py,sha256=Ysy3zF5lzPMz_asYDKeF5m0qgVT3tCt 
     | 
|
| 
       98 
98 
     | 
    
         
             
            openstef/tasks/utils/taskcontext.py,sha256=L9K14ycwgVxbIVUjH2DIn_QWbnu-OfxcGtQ1K9T6sus,5630
         
     | 
| 
       99 
99 
     | 
    
         
             
            openstef/validation/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
         
     | 
| 
       100 
100 
     | 
    
         
             
            openstef/validation/validation.py,sha256=628xaDbAm8B4AYtFOAn8_SXLjejNfULGCfX3hVf_mU0,11119
         
     | 
| 
       101 
     | 
    
         
            -
            openstef-3.4. 
     | 
| 
       102 
     | 
    
         
            -
            openstef-3.4. 
     | 
| 
       103 
     | 
    
         
            -
            openstef-3.4. 
     | 
| 
       104 
     | 
    
         
            -
            openstef-3.4. 
     | 
| 
       105 
     | 
    
         
            -
            openstef-3.4. 
     | 
| 
      
 101 
     | 
    
         
            +
            openstef-3.4.20.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
         
     | 
| 
      
 102 
     | 
    
         
            +
            openstef-3.4.20.dist-info/METADATA,sha256=iDsbzq_7dlisLeKayBIeemF1EYfPDVYXkquQ3k25Qe4,7392
         
     | 
| 
      
 103 
     | 
    
         
            +
            openstef-3.4.20.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
         
     | 
| 
      
 104 
     | 
    
         
            +
            openstef-3.4.20.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
         
     | 
| 
      
 105 
     | 
    
         
            +
            openstef-3.4.20.dist-info/RECORD,,
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |