Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from physXAI.models.ann.ann_design import ClassicalANNModel
from physXAI.preprocessing.preprocessing import PreprocessingSingleStep
from physXAI.preprocessing.constructed import Feature, FeatureExp
from physXAI.utils.logging import Logger

"""
This script demonstrates the usage of different sampling methods. It is not physically meaningful.

When creating a Feature, a sampling method can be specified.
For constructed features, no sampling method is necessary. It is assigned based on their corresponding base feature(s).

sampling_method (Union[str, int]): Time step of the input data used to predict the output.
- if None: Feature.get_default_sampling_method() is used
- if 'current' or 0: Current time step will be used for prediction.
- if 'previous' or 1: Previous time step will be used for prediction.
- if 'mean_over_interval': Mean between current and previous time step will be used.

Specify default sampling method using Feature.set_default_sampling_method(<your default sampling>).
If no default sampling method is specified by the user, 'previous' is used as default.

Constructed features must be built from features with sampling methods that apply the same time shift. Therefore,
constructed features can either base on features which have solely the sampling method 'current' (no time shift applied)
or on features which have one of the sampling methods ['previous','mean_over_interval'] (time shift of one unit applied).
"""

Feature.set_default_sampling_method(0)

# Setup up logger for saving
Logger.setup_logger(folder_name='different_sampling_methods_ann', override=True)

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

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

"""
The constructed features are automatically added to the data via 'physXAI.preprocessing.constructed.py'
Lagged inputs can be added directly based on the feature
"""
# create lags of reaTZon_y: reaTZon_y_lag1, reaTZon_y_lag2
x1 = Feature('reaTZon_y', sampling_method='previous')
lx1 = x1.lag(2) # for all lags of reaTZon_y, the shift will be set automatically as 'previous'

# create lag of weaSta_reaWeaTDryBul_y: weaSta_reaWeaTDryBul_y_lag1
x2 = Feature('weaSta_reaWeaTDryBul_y')
lx2 = x2.lag(1)

# create lag of oveHeaPumY_u: oveHeaPumY_u_lag1, oveHeaPumY_u_lag2
x3 = Feature('oveHeaPumY_u', sampling_method='mean_over_interval')
x3.lag(2)

# dummy Features
y = x1 + lx1[0]
z = y + x1
z.rename('example_feature_two') # since z is a constructed feature based on x1, its sampling_method will be previous
e = FeatureExp(x1-273.15, 'exp') # reduce x1 by 273.15, otherwise values are too high

# x1 and x3 have sampling methods 'previous' and 'mean_over_interval'.
# Since both of them apply a time shift of one, they can be combined in constructed features
a = x1 + x3

inputs.extend([z, e, a]) # add dummy features to inputs

# construct output
change_tair = x1 - lx1[0]
change_tair.rename('Change(T_air)')

# 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, time_step=4)

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

# Build & train Classical ANN
m = ClassicalANNModel(epochs=50)
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)
Loading