Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New dazls updates #503

Merged
merged 32 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
de3ed89
Updated the DAZLs model with a new string method to provide a summary…
ThomasNijsen Dec 21, 2023
c07a632
Added the new DAZLs model.
ThomasNijsen Jan 10, 2024
764704b
Added the new DAZLs model liscence.
ThomasNijsen Jan 10, 2024
0d4424f
Format Python code with Black
actions-user Jan 10, 2024
ee21a6d
Update create_component_forecast.py
FrankKr Jan 10, 2024
e782826
Format Python code with Black
actions-user Jan 10, 2024
a8f7796
Added a requirement for the joblib package.
ThomasNijsen Jan 10, 2024
c028e68
Removed previous dazls model.
ThomasNijsen Jan 10, 2024
19ff74e
Added the new compressed dazls model.
ThomasNijsen Jan 10, 2024
90126c1
Added the new DAZLs model in split form with changes to load it into …
ThomasNijsen Jan 11, 2024
6e380c2
Format Python code with Black
actions-user Jan 11, 2024
0a4640f
Added in the changes that were noted during review.
ThomasNijsen Jan 16, 2024
9158a7c
Merge branch 'new_dazls_updates' of https://github.com/OpenSTEF/opens…
ThomasNijsen Jan 16, 2024
f02e11f
Format Python code with Black
actions-user Jan 16, 2024
e3fade4
Updated version number.
ThomasNijsen Jan 16, 2024
6cd86f5
Merge branch 'new_dazls_updates' of https://github.com/OpenSTEF/opens…
ThomasNijsen Jan 16, 2024
4f83705
Updated package info.
ThomasNijsen Jan 17, 2024
a76f962
Resolved conflicts.
ThomasNijsen Jan 17, 2024
3369d06
Updated package data, stored old model in folders and adapted unit te…
ThomasNijsen Jan 18, 2024
0db858f
Resolved conflicts.
ThomasNijsen Jan 18, 2024
0556026
Updated dazls model for reduced size.
ThomasNijsen Jan 18, 2024
72365ab
Updated dazls model with pipeline features.
ThomasNijsen Feb 1, 2024
dcccf91
Merge branch 'main' into new_dazls_updates
ThomasNijsen Feb 1, 2024
2335d81
Update requirements.txt
ThomasNijsen Feb 1, 2024
c3aeff2
Updated the DAZLs class documentation and added a convenience functio…
ThomasNijsen Feb 29, 2024
36b6fa2
Merge branch 'main' into new_dazls_updates
ThomasNijsen Feb 29, 2024
85ef381
Format Python code with Black
actions-user Feb 29, 2024
1ce0f96
Implemented requested changes.
ThomasNijsen Feb 29, 2024
e993efd
Updated requested changes.
ThomasNijsen Feb 29, 2024
dd3d7fb
Ran black and added model card liscence.
ThomasNijsen Feb 29, 2024
09563fe
Updated model card liscence.
ThomasNijsen Feb 29, 2024
c8ee50c
Made code black compliant.
ThomasNijsen Feb 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_model_card.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"
# Model details : dazls_model_test_eval

## Description
**Model Name**: dazls_model_test_eval
**Author**: KTP, Alliander
**Model type**: Energy splitting model
**Model Architecture**: KNeighestNeighbours
**Date**: 2024-01-31

## Intended use
This is a DAZLs model aimed at determining the energy splits for substations.
Each of these splits are determined based on a set of features that are available in production,
and in this case have their origin in the Dutch energy grid.
Binary file not shown.
3 changes: 0 additions & 3 deletions openstef/data/dazls_model_old/dazls_stored.sav

This file was deleted.

3 changes: 0 additions & 3 deletions openstef/data/dazls_model_old/dazls_stored.sav.license

This file was deleted.

55 changes: 34 additions & 21 deletions openstef/model/regressors/dazls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,30 @@ class Dazls(BaseEstimator):

The model carries out wind and solar power prediction for unseen target substations using training data from
other substations with known components.
This model has two sub-models:

- domain model : a model taking a set of 'input' features of a substation and make an 'initial' prediction.
Input features can be features such as: weather, geospatial, total load, etc.
These features are always directly related to the components' size in some way.


- adaptation model : a model taking a set of 'meta' features of a substation and refines the domain model's
prediction. Next to the features, it is trained on the domain model's predictions.
'Meta' features are features related to the uncertainty of the data, and include:
variance of the total load, standard deviation of the total load, etc.

Any data-driven model can be plugged and used as the base for the domain and the adaptation model.

CAUTION : 'Meta' features should be kept out of the domain model, and vice versa input features should be
kept out the adaptation model.

For a full reference, see:
Teng, S.Y., van Nooten, C. C., van Doorn, J.M., Ottenbros, A., Huijbregts, M., Jansen, J.J.
Improving Near Real-Time Predictions of Renewable Electricity Production at Substation Level (Submitted)

Args:
- BaseEstimator (object) : a base model that can be used to carry out predictions.

"""

def __init__(self):
Expand All @@ -40,29 +57,12 @@ def __init__(self):
"total_substation", # Substation's measured total load
"lat", # Latitude
"lon", # Longitude
"solar_on", # Solar installed on substation: yes=1, no=0
"wind_on", # Wind installed on substation: yes=1, no=0
"hour", # Hour of the day
"minute", # Minute of the hour
"var0", # Variance of the total load
"var1", # Variance of the total pv load (only available for calibration substations)
"var2", # Variance of the total wind load (only available for calibration substations)
"sem0", # Standard Error of the Mean of the total load
"sem1", # Standard Error of the Mean of the total PV load (only available for calibration substations)
]
self.adaptation_model_input_columns = [
"total_substation",
"lat",
"lon",
"solar_on",
"wind_on",
"hour",
"minute",
"var0",
"var1",
"var2",
"sem0",
"sem1",
"var_total", # Variance of the total load
"sem_total", # Standard Error of the Mean of the total load
]
self.target_columns = ["total_wind_part", "total_solar_part"]

Expand Down Expand Up @@ -103,14 +103,20 @@ def fit(self, features, target):
)
self.adaptation_model.fit(adaptation_model_input, y_train)

def predict(self, x: np.array):
def predict(self, x: np.array, return_sub_preds: bool = False):
"""Make a prediction.

For the prediction we use the test data x. We use domain_model_input_columns and
adaptation_model_input_columns to separate x in test data for domain model and adaptation model respectively.

There is an option available to return the domain model and adaptation model predictions separately to more
easily investigate the effectiveness of the models.

Args:
x: domain_model_test_data, adaptation_model_test_data
return_sub_preds : a flag value indicating to return the predictions of the domain model and adaptation
model separately. (Default: False.)
Returns:
prediction: The output prediction after both models.

"""
Expand Down Expand Up @@ -139,7 +145,14 @@ def predict(self, x: np.array):
prediction = self.target_scaler.inverse_transform(
adaptation_model_test_data_pred
)
return prediction

if return_sub_preds:
prediction_domain = self.target_scaler.inverse_transform(
domain_model_test_data_pred
)
return prediction, prediction_domain
else:
return prediction

def score(self, truth, prediction):
"""Evaluation of the prediction's output.
Expand Down
2 changes: 1 addition & 1 deletion openstef/pipeline/create_component_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# Set the path for the Dazls stored model
DAZLS_STORED = str(
PROJECT_ROOT / "openstef" / "data" / "dazls_model_3.4.0" / "dazls_stored_3.4.0_"
PROJECT_ROOT / "openstef" / "data" / "dazls_model_3.4.7" / "dazls_stored_3.4.7_"
)


Expand Down
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ def read_long_description_from_readme():
# for more information
package_data={
# Include anything in the data directory
"openstef": [
"data/*",
"data/dazls_model_3.4.0/*",
"*.license",
]
"openstef": ["data/*", "data/dazls_model_3.4.7/*", "*.license"]
},
python_requires=">=3.9.0",
install_requires=read_requirements_from_file(),
Expand Down
2 changes: 1 addition & 1 deletion test/unit/pipeline/test_create_component_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_load_dazls_model(self):
PROJECT_ROOT / "openstef/data/dazls_model_3.2.49/dazls_stored_3.2.49.sav"
)
new_model_file = str(
PROJECT_ROOT / "openstef/data/dazls_model_3.4.0/dazls_stored_3.4.0_"
PROJECT_ROOT / "openstef/data/dazls_model_3.4.7/dazls_stored_3.4.7_"
)

self.assertRaises(Exception, joblib.load, old_model_file)
Expand Down
Loading