openstef 3.4.24__tar.gz → 3.4.25__tar.gz
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-3.4.24 → openstef-3.4.25}/PKG-INFO +1 -1
- openstef-3.4.25/openstef/model/regressors/dazls.py +112 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/pipeline/create_component_forecast.py +2 -19
- {openstef-3.4.24 → openstef-3.4.25}/openstef.egg-info/PKG-INFO +1 -1
- {openstef-3.4.24 → openstef-3.4.25}/openstef.egg-info/SOURCES.txt +0 -18
- {openstef-3.4.24 → openstef-3.4.25}/setup.py +1 -1
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model.z +0 -0
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model.z.license +0 -3
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_features.z +0 -0
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_features.z.license +0 -3
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_scaler.z +0 -0
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_scaler.z.license +0 -3
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model.z +0 -0
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model.z.license +0 -3
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model_features.z +0 -2
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model_features.z.license +0 -3
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model_scaler.z +0 -0
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model_scaler.z.license +0 -3
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_model_card.md +0 -14
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_model_card.md.license +0 -3
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target.z +0 -0
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target.z.license +0 -3
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target_scaler.z +0 -0
- openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target_scaler.z.license +0 -3
- openstef-3.4.24/openstef/model/regressors/dazls.py +0 -191
- {openstef-3.4.24 → openstef-3.4.25}/LICENSE +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/README.md +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/__main__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/app_settings.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/data/dutch_holidays_2020-2022.csv +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/data/dutch_holidays_2020-2022.csv.license +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/data/pv_single_coefs.csv +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/data/pv_single_coefs.csv.license +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/data_classes/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/data_classes/data_prep.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/data_classes/model_specifications.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/data_classes/prediction_job.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/data_classes/split_function.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/enums.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/exceptions.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/apply_features.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/data_preparation.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/feature_adder.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/feature_applicator.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/general.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/holiday_features.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/lag_features.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/missing_values_transformer.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/weather_features.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/metrics/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/metrics/figure.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/metrics/metrics.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/metrics/reporter.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/basecase.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/confidence_interval_applicator.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/fallback.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/metamodels/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/metamodels/grouped_regressor.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/metamodels/missing_values_handler.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/model_creator.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/objective.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/objective_creator.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/arima.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/custom_regressor.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/lgbm.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/linear.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/linear_quantile.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/regressor.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/xgb.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/xgb_multioutput_quantile.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/regressors/xgb_quantile.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/serializer.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model/standard_deviation_generator.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model_selection/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/model_selection/model_selection.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/monitoring/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/monitoring/performance_meter.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/monitoring/teams.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/pipeline/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/pipeline/create_basecase_forecast.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/pipeline/create_forecast.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/pipeline/optimize_hyperparameters.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/pipeline/train_create_forecast_backtest.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/pipeline/train_model.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/pipeline/utils.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/postprocessing/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/postprocessing/postprocessing.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/preprocessing/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/preprocessing/preprocessing.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/settings.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/calculate_kpi.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/create_basecase_forecast.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/create_components_forecast.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/create_forecast.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/create_solar_forecast.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/create_wind_forecast.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/optimize_hyperparameters.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/split_forecast.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/train_model.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/utils/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/utils/dependencies.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/utils/predictionjobloop.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/tasks/utils/taskcontext.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/validation/__init__.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef/validation/validation.py +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef.egg-info/dependency_links.txt +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef.egg-info/requires.txt +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/openstef.egg-info/top_level.txt +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/pyproject.toml +0 -0
- {openstef-3.4.24 → openstef-3.4.25}/setup.cfg +0 -0
@@ -0,0 +1,112 @@
|
|
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
|
+
"""This module defines the DAZL model."""
|
5
|
+
import numpy as np
|
6
|
+
from sklearn.base import BaseEstimator
|
7
|
+
from sklearn.compose import TransformedTargetRegressor
|
8
|
+
from sklearn.linear_model import LinearRegression
|
9
|
+
from sklearn.metrics import mean_squared_error, r2_score
|
10
|
+
from sklearn.pipeline import Pipeline
|
11
|
+
from sklearn.preprocessing import MinMaxScaler
|
12
|
+
|
13
|
+
|
14
|
+
class Dazls(BaseEstimator):
|
15
|
+
"""DAZLS model.
|
16
|
+
|
17
|
+
The model carries out wind and solar power prediction for unseen target substations using training data from other
|
18
|
+
substations with known components.
|
19
|
+
|
20
|
+
"""
|
21
|
+
|
22
|
+
model_: Pipeline
|
23
|
+
|
24
|
+
def __init__(self):
|
25
|
+
"""Initialize DAZL model."""
|
26
|
+
self.__name__ = "DAZLS"
|
27
|
+
|
28
|
+
regressor = TransformedTargetRegressor(
|
29
|
+
regressor=LinearRegression(),
|
30
|
+
transformer=MinMaxScaler(clip=True),
|
31
|
+
)
|
32
|
+
|
33
|
+
self.model_ = Pipeline(
|
34
|
+
[("scaler", MinMaxScaler(clip=True)), ("regressor", regressor)]
|
35
|
+
)
|
36
|
+
|
37
|
+
# The input columns for the domain and adaptation models (with description)
|
38
|
+
self.baseline_input_columns = [
|
39
|
+
"radiation", # Weather parameter
|
40
|
+
"windspeed_100m", # Weather parameter
|
41
|
+
"total_load",
|
42
|
+
]
|
43
|
+
self.target_columns = ["total_wind_part", "total_solar_part"]
|
44
|
+
|
45
|
+
def fit(self, features, target):
|
46
|
+
"""Fit the model.
|
47
|
+
|
48
|
+
In this function we scale the input of the domain and adaptation models of the DAZLS MODEL. Then we fit the
|
49
|
+
two models. We separate the features into domain_model_input, adaptation_model_input and target, and we use them
|
50
|
+
for the fitting and the training of the models.
|
51
|
+
|
52
|
+
Args:
|
53
|
+
features: inputs for domain and adaptation model (domain_model_input, adaptation_model_input)
|
54
|
+
target: the expected output (y_train)
|
55
|
+
"""
|
56
|
+
x, y = (
|
57
|
+
features.loc[:, self.baseline_input_columns],
|
58
|
+
target.loc[:, self.target_columns],
|
59
|
+
)
|
60
|
+
|
61
|
+
self.model_.fit(x, y)
|
62
|
+
|
63
|
+
def predict(self, x: np.array):
|
64
|
+
"""Make a prediction.
|
65
|
+
|
66
|
+
For the prediction we use the test data x. We use domain_model_input_columns and
|
67
|
+
adaptation_model_input_columns to separate x in test data for domain model and adaptation model respectively.
|
68
|
+
|
69
|
+
There is an option available to return the domain model and adaptation model predictions separately to more
|
70
|
+
easily investigate the effectiveness of the models.
|
71
|
+
|
72
|
+
Args:
|
73
|
+
x: domain_model_test_data, adaptation_model_test_data
|
74
|
+
return_sub_preds : a flag value indicating to return the predictions of the domain model and adaptation
|
75
|
+
model separately. (Default: False.)
|
76
|
+
|
77
|
+
Returns:
|
78
|
+
prediction: The output prediction after both models.
|
79
|
+
"""
|
80
|
+
model_test_data = x.loc[:, self.baseline_input_columns]
|
81
|
+
|
82
|
+
return self.model_.predict(model_test_data)
|
83
|
+
|
84
|
+
def score(self, truth, prediction):
|
85
|
+
"""Evaluation of the prediction's output.
|
86
|
+
|
87
|
+
Args:
|
88
|
+
truth: real values
|
89
|
+
prediction: predicted values
|
90
|
+
|
91
|
+
Returns:
|
92
|
+
RMSE and R2 scores
|
93
|
+
"""
|
94
|
+
rmse = (mean_squared_error(truth, prediction)) ** 0.5
|
95
|
+
r2_score_value = r2_score(truth, prediction)
|
96
|
+
return rmse, r2_score_value
|
97
|
+
|
98
|
+
def __str__(self):
|
99
|
+
"""String method of the DAZLs model, provides a summary of the model for easy inspection.
|
100
|
+
|
101
|
+
Returns:
|
102
|
+
Summary represented by a string
|
103
|
+
"""
|
104
|
+
summary_str = (
|
105
|
+
f"{self.__name__} model summary:\n\n"
|
106
|
+
f"Model: {self.model_} \n"
|
107
|
+
f"\tInput columns: {self.baseline_input_columns} \n"
|
108
|
+
f"\tScaler: {self.model_['scaler']} \n\n"
|
109
|
+
f"\tRegressor: {self.model_['regressor']} \n\n"
|
110
|
+
)
|
111
|
+
|
112
|
+
return summary_str
|
@@ -18,7 +18,7 @@ from openstef.settings import Settings
|
|
18
18
|
|
19
19
|
# Set the path for the Dazls stored model
|
20
20
|
DAZLS_STORED = str(
|
21
|
-
PROJECT_ROOT / "openstef" / "data" / "dazls_model_3.4.
|
21
|
+
PROJECT_ROOT / "openstef" / "data" / "dazls_model_3.4.24" / "dazls_stored_3.4.24_"
|
22
22
|
)
|
23
23
|
|
24
24
|
|
@@ -113,24 +113,7 @@ def create_components_forecast_pipeline(
|
|
113
113
|
# Save and load the model as .sav file (or as .z file)
|
114
114
|
# For the code contact: korte.termijn.prognoses@alliander.com
|
115
115
|
dazls_model = Dazls()
|
116
|
-
dazls_model.
|
117
|
-
dazls_model.domain_model_scaler = joblib.load(
|
118
|
-
DAZLS_STORED + "domain_model_scaler.z"
|
119
|
-
)
|
120
|
-
dazls_model.domain_model_input_columns = joblib.load(
|
121
|
-
DAZLS_STORED + "domain_model_features.z"
|
122
|
-
)
|
123
|
-
|
124
|
-
dazls_model.adaptation_model = joblib.load(DAZLS_STORED + "adaptation_model.z")
|
125
|
-
dazls_model.adaptation_model_scaler = joblib.load(
|
126
|
-
DAZLS_STORED + "adaptation_model_scaler.z"
|
127
|
-
)
|
128
|
-
dazls_model.adaptation_model_input_columns = joblib.load(
|
129
|
-
DAZLS_STORED + "adaptation_model_features.z"
|
130
|
-
)
|
131
|
-
|
132
|
-
dazls_model.target_columns = joblib.load(DAZLS_STORED + "target.z")
|
133
|
-
dazls_model.target_scaler = joblib.load(DAZLS_STORED + "target_scaler.z")
|
116
|
+
dazls_model.model_ = joblib.load(DAZLS_STORED + "baseline_model.z")
|
134
117
|
|
135
118
|
logger.info("DAZLS model loaded", dazls_model=str(dazls_model))
|
136
119
|
|
@@ -18,24 +18,6 @@ openstef/data/dutch_holidays_2020-2022.csv
|
|
18
18
|
openstef/data/dutch_holidays_2020-2022.csv.license
|
19
19
|
openstef/data/pv_single_coefs.csv
|
20
20
|
openstef/data/pv_single_coefs.csv.license
|
21
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model.z
|
22
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model.z.license
|
23
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_features.z
|
24
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_features.z.license
|
25
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_scaler.z
|
26
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_scaler.z.license
|
27
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model.z
|
28
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model.z.license
|
29
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model_features.z
|
30
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model_features.z.license
|
31
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model_scaler.z
|
32
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_domain_model_scaler.z.license
|
33
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_model_card.md
|
34
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_model_card.md.license
|
35
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target.z
|
36
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target.z.license
|
37
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target_scaler.z
|
38
|
-
openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_target_scaler.z.license
|
39
21
|
openstef/data_classes/__init__.py
|
40
22
|
openstef/data_classes/data_prep.py
|
41
23
|
openstef/data_classes/model_specifications.py
|
@@ -29,7 +29,7 @@ def read_long_description_from_readme():
|
|
29
29
|
|
30
30
|
setup(
|
31
31
|
name="openstef",
|
32
|
-
version="3.4.
|
32
|
+
version="3.4.25",
|
33
33
|
packages=find_packages(include=["openstef", "openstef.*"]),
|
34
34
|
description="Open short term energy forecaster",
|
35
35
|
long_description=read_long_description_from_readme(),
|
Binary file
|
openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_features.z
DELETED
Binary file
|
openstef-3.4.24/openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_adaptation_model_scaler.z
DELETED
Binary file
|
Binary file
|
Binary file
|
@@ -1,14 +0,0 @@
|
|
1
|
-
"
|
2
|
-
# Model details : dazls_model_test_eval
|
3
|
-
|
4
|
-
## Description
|
5
|
-
**Model Name**: dazls_model_test_eval
|
6
|
-
**Author**: KTP, Alliander
|
7
|
-
**Model type**: Energy splitting model
|
8
|
-
**Model Architecture**: KNeighestNeighbours
|
9
|
-
**Date**: 2024-01-31
|
10
|
-
|
11
|
-
## Intended use
|
12
|
-
This is a DAZLs model aimed at determining the energy splits for substations.
|
13
|
-
Each of these splits are determined based on a set of features that are available in production,
|
14
|
-
and in this case have their origin in the Dutch energy grid.
|
Binary file
|
Binary file
|
@@ -1,191 +0,0 @@
|
|
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
|
-
"""This module defines the DAZL model."""
|
5
|
-
import numpy as np
|
6
|
-
from sklearn.base import BaseEstimator
|
7
|
-
from sklearn.metrics import mean_squared_error, r2_score
|
8
|
-
from sklearn.neighbors import KNeighborsRegressor
|
9
|
-
from sklearn.preprocessing import MinMaxScaler
|
10
|
-
from sklearn.utils import shuffle
|
11
|
-
|
12
|
-
|
13
|
-
class Dazls(BaseEstimator):
|
14
|
-
"""DAZLS model.
|
15
|
-
|
16
|
-
The model carries out wind and solar power prediction for unseen target substations using training data from
|
17
|
-
other substations with known components.
|
18
|
-
This model has two sub-models:
|
19
|
-
|
20
|
-
- domain model : a model taking a set of 'input' features of a substation and make an 'initial' prediction.
|
21
|
-
Input features can be features such as: weather, geospatial, total load, etc.
|
22
|
-
These features are always directly related to the components' size in some way.
|
23
|
-
|
24
|
-
|
25
|
-
- adaptation model : a model taking a set of 'meta' features of a substation and refines the domain model's
|
26
|
-
prediction. Next to the features, it is trained on the domain model's predictions.
|
27
|
-
'Meta' features are features related to the uncertainty of the data, and include:
|
28
|
-
variance of the total load, standard deviation of the total load, etc.
|
29
|
-
|
30
|
-
Any data-driven model can be plugged and used as the base for the domain and the adaptation model.
|
31
|
-
|
32
|
-
CAUTION : 'Meta' features should be kept out of the domain model, and vice versa input features should be
|
33
|
-
kept out the adaptation model.
|
34
|
-
|
35
|
-
For a full reference, see:
|
36
|
-
Teng, S.Y., van Nooten, C. C., van Doorn, J.M., Ottenbros, A., Huijbregts, M., Jansen, J.J.
|
37
|
-
Improving Near Real-Time Predictions of Renewable Electricity Production at Substation Level (Submitted)
|
38
|
-
|
39
|
-
Args:
|
40
|
-
- BaseEstimator (object) : a base model that can be used to carry out predictions.
|
41
|
-
|
42
|
-
"""
|
43
|
-
|
44
|
-
def __init__(self):
|
45
|
-
"""Initialize DAZL model."""
|
46
|
-
self.__name__ = "DAZLS"
|
47
|
-
self.domain_model_scaler = MinMaxScaler(clip=True)
|
48
|
-
self.adaptation_model_scaler = MinMaxScaler(clip=True)
|
49
|
-
self.target_scaler = MinMaxScaler(clip=True)
|
50
|
-
self.domain_model = KNeighborsRegressor(n_neighbors=20, weights="uniform")
|
51
|
-
self.adaptation_model = KNeighborsRegressor(n_neighbors=20, weights="uniform")
|
52
|
-
|
53
|
-
# The input columns for the domain and adaptation models (with description)
|
54
|
-
self.domain_model_input_columns = [
|
55
|
-
"radiation", # Weather parameter
|
56
|
-
"windspeed_100m", # Weather parameter
|
57
|
-
"total_substation", # Substation's measured total load
|
58
|
-
"lat", # Latitude
|
59
|
-
"lon", # Longitude
|
60
|
-
"hour", # Hour of the day
|
61
|
-
"minute", # Minute of the hour
|
62
|
-
]
|
63
|
-
self.adaptation_model_input_columns = [
|
64
|
-
"var_total", # Variance of the total load
|
65
|
-
"sem_total", # Standard Error of the Mean of the total load
|
66
|
-
]
|
67
|
-
self.target_columns = ["total_wind_part", "total_solar_part"]
|
68
|
-
|
69
|
-
def fit(self, features, target):
|
70
|
-
"""Fit the model.
|
71
|
-
|
72
|
-
In this function we scale the input of the domain and adaptation models of the DAZLS MODEL. Then we fit the
|
73
|
-
two models. We separate the features into domain_model_input, adaptation_model_input and target, and we use them
|
74
|
-
for the fitting and the training of the models.
|
75
|
-
|
76
|
-
Args:
|
77
|
-
features: inputs for domain and adaptation model (domain_model_input, adaptation_model_input)
|
78
|
-
target: the expected output (y_train)
|
79
|
-
|
80
|
-
"""
|
81
|
-
x, x2, y = (
|
82
|
-
features.loc[:, self.domain_model_input_columns],
|
83
|
-
features.loc[:, self.adaptation_model_input_columns],
|
84
|
-
target.loc[:, self.target_columns],
|
85
|
-
)
|
86
|
-
domain_model_input, adaptation_model_input, y_train = shuffle(
|
87
|
-
x, x2, y, random_state=999
|
88
|
-
) # just shuffling
|
89
|
-
|
90
|
-
self.domain_model_scaler.fit(domain_model_input)
|
91
|
-
self.adaptation_model_scaler.fit(adaptation_model_input)
|
92
|
-
self.target_scaler.fit(y_train)
|
93
|
-
domain_model_input = self.domain_model_scaler.transform(domain_model_input)
|
94
|
-
adaptation_model_input = self.adaptation_model_scaler.transform(
|
95
|
-
adaptation_model_input
|
96
|
-
)
|
97
|
-
y_train = self.target_scaler.transform(y_train)
|
98
|
-
|
99
|
-
self.domain_model.fit(domain_model_input, y_train)
|
100
|
-
domain_model_pred = self.domain_model.predict(domain_model_input)
|
101
|
-
adaptation_model_input = np.concatenate(
|
102
|
-
(adaptation_model_input, domain_model_pred), axis=1
|
103
|
-
)
|
104
|
-
self.adaptation_model.fit(adaptation_model_input, y_train)
|
105
|
-
|
106
|
-
def predict(self, x: np.array, return_sub_preds: bool = False):
|
107
|
-
"""Make a prediction.
|
108
|
-
|
109
|
-
For the prediction we use the test data x. We use domain_model_input_columns and
|
110
|
-
adaptation_model_input_columns to separate x in test data for domain model and adaptation model respectively.
|
111
|
-
|
112
|
-
There is an option available to return the domain model and adaptation model predictions separately to more
|
113
|
-
easily investigate the effectiveness of the models.
|
114
|
-
|
115
|
-
Args:
|
116
|
-
x: domain_model_test_data, adaptation_model_test_data
|
117
|
-
return_sub_preds : a flag value indicating to return the predictions of the domain model and adaptation
|
118
|
-
model separately. (Default: False.)
|
119
|
-
|
120
|
-
Returns:
|
121
|
-
prediction: The output prediction after both models.
|
122
|
-
|
123
|
-
"""
|
124
|
-
domain_model_test_data, adaptation_model_test_data = (
|
125
|
-
x.loc[:, self.domain_model_input_columns],
|
126
|
-
x.loc[:, self.adaptation_model_input_columns],
|
127
|
-
)
|
128
|
-
# Rescale test data for both models (if required)
|
129
|
-
domain_model_test_data_scaled = self.domain_model_scaler.transform(
|
130
|
-
domain_model_test_data
|
131
|
-
)
|
132
|
-
adaptation_model_test_data_scaled = self.adaptation_model_scaler.transform(
|
133
|
-
adaptation_model_test_data
|
134
|
-
)
|
135
|
-
# Use the scaled data to make domain_model_prediction
|
136
|
-
domain_model_test_data_pred = self.domain_model.predict(
|
137
|
-
domain_model_test_data_scaled
|
138
|
-
)
|
139
|
-
# Use the domain_model_prediction to make adaptation_model_prediction
|
140
|
-
adaptation_model_test_data_pred = self.adaptation_model.predict(
|
141
|
-
np.concatenate(
|
142
|
-
[adaptation_model_test_data_scaled, domain_model_test_data_pred], axis=1
|
143
|
-
)
|
144
|
-
)
|
145
|
-
# Rescale adaptation_model_prediction (if required)
|
146
|
-
prediction = self.target_scaler.inverse_transform(
|
147
|
-
adaptation_model_test_data_pred
|
148
|
-
)
|
149
|
-
|
150
|
-
if return_sub_preds:
|
151
|
-
prediction_domain = self.target_scaler.inverse_transform(
|
152
|
-
domain_model_test_data_pred
|
153
|
-
)
|
154
|
-
return prediction, prediction_domain
|
155
|
-
else:
|
156
|
-
return prediction
|
157
|
-
|
158
|
-
def score(self, truth, prediction):
|
159
|
-
"""Evaluation of the prediction's output.
|
160
|
-
|
161
|
-
Args:
|
162
|
-
truth: real values
|
163
|
-
prediction: predicted values
|
164
|
-
|
165
|
-
Returns:
|
166
|
-
RMSE and R2 scores
|
167
|
-
|
168
|
-
"""
|
169
|
-
rmse = (mean_squared_error(truth, prediction)) ** 0.5
|
170
|
-
r2_score_value = r2_score(truth, prediction)
|
171
|
-
return rmse, r2_score_value
|
172
|
-
|
173
|
-
def __str__(self):
|
174
|
-
"""String method of the DAZLs model, provides a summary of the model for easy inspection.
|
175
|
-
|
176
|
-
Returns:
|
177
|
-
Summary represented by a string
|
178
|
-
|
179
|
-
"""
|
180
|
-
summary_str = (
|
181
|
-
f"{self.__name__} model summary:\n\n"
|
182
|
-
f"Domain Model: {self.domain_model} \n"
|
183
|
-
f"\tInput columns: {self.domain_model_input_columns} \n"
|
184
|
-
f"\tScaler: {self.domain_model_scaler} \n\n"
|
185
|
-
f"Adaptation Model: {self.adaptation_model} \n"
|
186
|
-
f"\tInput columns: {self.adaptation_model_input_columns} \n"
|
187
|
-
f"\tScaler: {self.adaptation_model_scaler} \n\n"
|
188
|
-
f"Target columns: {self.target_columns}"
|
189
|
-
)
|
190
|
-
|
191
|
-
return summary_str
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{openstef-3.4.24 → openstef-3.4.25}/openstef/feature_engineering/missing_values_transformer.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|