Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1ffcccb
Added function to convert shift to dict
Nov 20, 2025
b8706cc
Added unittests for function preprocessing.convert_shift_to_dict
Nov 20, 2025
499b4c7
Small import improvement
Nov 20, 2025
f404396
Bug fix for backwards compatibility with python 3.9
Nov 21, 2025
15c2ed7
Corrected bug fix for backwards compatibility with python 3.9
Nov 21, 2025
690cb96
Merge remote-tracking branch 'remotes/origin/main' into 45-add-interp…
Nov 21, 2025
828c64d
partly integrated new structure for shifting inputs and outputs
Nov 21, 2025
95ff10f
Merge remote-tracking branch 'remotes/origin/main' into 45-add-interp…
Nov 26, 2025
e2986de
Fixed error occurring with recursive_feature_elimination
Nov 26, 2025
9973f0c
Implemented new structure and methods for shifting input data
Nov 26, 2025
0d3783b
Fixed small error with feature selection test script
Nov 28, 2025
2d23228
Fixed error in feature construction
Nov 28, 2025
5ba2f22
Update coverage badge [skip ci]
actions-user Nov 29, 2025
4b12e2b
Merge remote-tracking branch 'remotes/origin/main' into 45-add-interp…
Dec 3, 2025
3e0a8ad
Merge branch '45-add-interpolation-methods-for-input-output' of https…
Dec 3, 2025
3dec440
Update coverage badge [skip ci]
actions-user Dec 3, 2025
88b1ccc
implemented custom default for shift
Dec 3, 2025
ef9a8d4
Updated docstrings
Dec 3, 2025
b458803
Implemented test and example for different shifts
Dec 3, 2025
23ac15b
Update coverage badge [skip ci]
actions-user Dec 3, 2025
80815ee
reduce number of epochs for more efficient testing
Dec 3, 2025
367624f
implemented handling of constructed features including lagged features
Dec 5, 2025
567efcd
Partly integrated shift as attribute sampling_method in Feature
Dec 5, 2025
e0fc769
Implemented input list as list of Features and str
Dec 7, 2025
be1365b
Update coverage badge [skip ci]
actions-user Dec 7, 2025
7d439f8
Fix SyntaxError in python versions earlier than 3.12
Dec 7, 2025
f160948
Added DeprecationWarning for shift parameter, updated testing and exa…
Dec 7, 2025
11d1719
Fixed small mistake regarding DataFrame length
Dec 7, 2025
8d9af45
Fixed testing bug
Dec 7, 2025
8f8c377
Update coverage badge [skip ci]
actions-user Dec 7, 2025
c42f424
Updated testing for sampling method as attribute of Feature
Dec 10, 2025
8323ee5
Fixed error: char not allowed in folder name
Dec 10, 2025
8fd0093
fixed bug with property & added testing for deprecated shift
Dec 10, 2025
0496761
Fixed small error in testing script
Dec 10, 2025
03335f6
fixed small syntax error with older python versions
Dec 10, 2025
9450d0f
Moved default_sampling_method from FeatureConstruction to Feature
Dec 10, 2025
93068a0
Deleted deprecated code
Dec 11, 2025
096a863
Implemented handling of constructed outputs
Dec 17, 2025
203c601
Update coverage badge [skip ci]
actions-user Dec 17, 2025
bafeb3c
restructured sampling_method
Dec 17, 2025
79db1dc
fixed testing bug
Dec 17, 2025
c2f002a
Refactoring of sampling, corrected use of UserWarnings
Dec 18, 2025
ae0e378
Merge remote-tracking branch 'remotes/origin/main' into 45-add-interp…
Dec 21, 2025
3cbcdba
Updated
PatrickHenkel Dec 22, 2025
6dbe18a
Merge branch '45-add-interpolation-methods-for-input-output' of https…
PatrickHenkel Dec 22, 2025
69a27f6
Merge remote-tracking branch 'remotes/origin/main' into 45-add-interp…
Dec 22, 2025
1af0fb4
Updated
Dec 24, 2025
bcef26e
Updated
Dec 24, 2025
095516e
corrected usage of input list
Jan 2, 2026
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
6 changes: 3 additions & 3 deletions build/reports/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions executables/bestest_hydronic_heat_pump/Dummy_shifting.py
Comment thread
SiAndRo2002 marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from physXAI.models.ann.ann_design import ClassicalANNModel
from physXAI.preprocessing.preprocessing import PreprocessingSingleStep
from physXAI.preprocessing.constructed import Feature
from physXAI.utils.logging import Logger


"""
This script demonstrates the usage of different shifts. It is not physically meaningful.
"""
# Setup up logger for saving
Logger.setup_logger(folder_name='Dummy_shifting_ann', override=True)

# File path to data
file_path = r"data/bestest_hydronic_heat_pump/pid_data.csv"

# List of input features. Can include constructed features and lagged inputs
inputs = ['reaTZon_y', 'reaTZon_y_lag1', 'reaTZon_y_lag2', 'weaSta_reaWeaTDryBul_y', 'weaSta_reaWeaTDryBul_y_lag1',
'weaSta_reaWeaHDirNor_y', 'oveHeaPumY_u', 'oveHeaPumY_u_lag1', 'oveHeaPumY_u_lag2']
# Output feature
output = 'Change(T_zone)'

"""
The constructed features are automatically added to the data via 'physXAI.preprocessing.constructed.py'
Lagged inputs can be added directly based on the feature
"""
x1 = Feature('reaTZon_y')
x1.lag(2) # reaTZon_y_lag1, reaTZon_y_lag2
x2 = Feature('weaSta_reaWeaTDryBul_y')
x2.lag(1) # weaSta_reaWeaTDryBul_y_lag1
x3 = Feature('oveHeaPumY_u')
x3.lag(2) # oveHeaPumY_u_lag1, oveHeaPumY_u_lag2


"""
shift (Union[int, str, dict]): Time step of the input data used to predict the output.
- If a single int or str is given, it applies to all inputs.
- If a dict is provided, it can specify different shifts for individual inputs.
- If not all inputs are specified in the dict, unspecified inputs will use a default value (autocomplete).
Examples:
- shift = 0 or shift = 'current': Current time step will be used for prediction.
- shift = 1 or shift = 'previous': Previous values will be used for prediction.
- shift = 'mean_over_interval': Mean between current and previous time step will be used.
- shift = {
'inp_1': 1,
'inp_2': 'mean_over_interval',
'_default': 0, # current time step will be used for all inputs not specified in the dict
# If no custom default value is given in dict, 'previous' will be used as default
}
"""
shift = {
'reaTZon_y': 'previous', # for all lags of reaTZon_y, the shift will be set automatically
'weaSta_reaWeaHDirNor_y': 'mean_over_interval',
'_default': 0,
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should include this as part of Feature with attribute sampling_method. Default should be None, and there should be a class attribute default_sampling_method that is used if None
Shift should be removed from preprocessing (not backwards compatible, but necessary to maintain usability)


# Create Training data
# Time step defines target sampling: if original sampling of data is in 15min intervals, it is resampled to 1h intervals for time_step=4
# Hence, if the shift method of an input is defined as 'mean_over_interval', the mean over the last hour is taken as input
prep = PreprocessingSingleStep(inputs, output, shift=shift, time_step=4)

# Process Training data
td = prep.pipeline(file_path)

# Classical ANN
m = ClassicalANNModel(epochs=50)

# Training pipeline
model = m.pipeline(td)

# Log setup of preprocessing and model as json
Logger.log_setup(prep, m)
# Log training data as pickle
Logger.save_training_data(td)
12 changes: 9 additions & 3 deletions physXAI/preprocessing/constructed.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,18 +560,24 @@ def get_feature(name: str) -> Union[FeatureBase, None]:
return None

@staticmethod
def process(df: DataFrame):
def process(df: DataFrame, feature_names: list[str] = None):
"""
Processes the input DataFrame by applying all registered feature transformations in order.
Each feature's `process` method is called, which typically adds a new column to `df`
if it doesn't already exist.

Args:
df (DataFrame): The DataFrame to process and add features to.
feature_names (list[str]): optional parameter to only process those features given in feature_names
"""

for f in FeatureConstruction.features:
f.process(df)
if feature_names is None:
for f in FeatureConstruction.features:
f.process(df)
else:
for f in FeatureConstruction.features:
if f.feature in feature_names:
f.process(df)

@staticmethod
def get_config() -> list:
Expand Down
Loading