forked from pascme05/BaseNILM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdlPara.py
More file actions
173 lines (153 loc) · 13.8 KB
/
mdlPara.py
File metadata and controls
173 lines (153 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#######################################################################################################################
#######################################################################################################################
# Title: BaseNILM toolkit for energy disaggregation
# Topic: Non-intrusive load monitoring utilising machine learning, pattern matching and source separation
# File: mdlPara
# Date: 16.06.2024
# Author: Dr. Pascal A. Schirmer
# Version: V.1.0
# Copyright: Pascal Schirmer
#######################################################################################################################
#######################################################################################################################
#######################################################################################################################
# Import libs
#######################################################################################################################
# ==============================================================================
# Internal
# ==============================================================================
# ==============================================================================
# External
# ==============================================================================
#######################################################################################################################
# Function
#######################################################################################################################
def mdlPara(setupMdl):
###################################################################################################################
# Init
###################################################################################################################
setupMdl['feat'] = {}
setupMdl['feat2D'] = {}
setupMdl['feat_roll'] = {}
###################################################################################################################
# General Model Parameters
###################################################################################################################
# ==============================================================================
# Hyperparameters
# ==============================================================================
setupMdl['batch'] = 1000 # batch size for training and testing
setupMdl['epoch'] = 50 # number of epochs for training
setupMdl['patience'] = 10 # number of epochs as patience during training
setupMdl['valsteps'] = 25 # number of validation steps
setupMdl['shuffle'] = 'False' # shuffling data before training (after splitting data)
setupMdl['verbose'] = 2 # level of detail for showing training information (0 silent)
# ==============================================================================
# Solver Parameters
# ==============================================================================
setupMdl['loss'] = 'mae' # loss function 1) mae, 2) mse, 3) BinaryCrossentropy, 4) KLDivergence, 5) accuracy
setupMdl['metric'] = 'TECA' # loss metric 1) mae, 2) mse, 3) BinaryCrossentropy, 4) KLDivergence, 5) accuracy, 6) TECA
setupMdl['opt'] = 'Adam' # solver 1) Adam, 2) RMSprop, 3) SGD
setupMdl['lr'] = 1e-3 # learning rate
setupMdl['beta1'] = 0.9 # first moment decay
setupMdl['beta2'] = 0.999 # second moment decay
setupMdl['eps'] = 1e-08 # small constant for stability
setupMdl['rho'] = 0.9 # discounting factor for the history/coming gradient
setupMdl['mom'] = 0.0 # momentum
###################################################################################################################
# Sklearn Parameters
###################################################################################################################
# ------------------------------------------
# RF
# ------------------------------------------
setupMdl['SK_RF_depth'] = 5 # maximum depth of the tree
setupMdl['SK_RF_state'] = 0 # number of states
setupMdl['SK_RF_estimators'] = 16 # number of trees in the forest
# ------------------------------------------
# SVM
# ------------------------------------------
setupMdl['SK_SVM_kernel'] = 'rbf' # kernel function of the SVM ‘linear’, ‘poly’, ‘rbf’, ‘sigmoid’
setupMdl['SK_SVM_C'] = 100 # regularization
setupMdl['SK_SVM_gamma'] = 0.1 # kernel coefficient
setupMdl['SK_SVM_epsilon'] = 0.1
# ------------------------------------------
# KNN
# ------------------------------------------
setupMdl['SK_KNN_neighbors'] = 5 # number of neighbors
###################################################################################################################
# Pattern Matching Parameters
###################################################################################################################
# ------------------------------------------
# General
# ------------------------------------------
setupMdl['PM_Gen_cDTW'] = 0.01 # pattern matching constraint on mdl size (%)
# ------------------------------------------
# DTW
# ------------------------------------------
setupMdl['PM_DTW_metric'] = 'euclidean' # dtw warping path metric
setupMdl['PM_DTW_const'] = 'none' # constraint on the warping path 1) none, 2) sakoechiba or 3) itakura
# ------------------------------------------
# GAK
# ------------------------------------------
setupMdl['PM_GAK_sigma'] = 2000 # kernel parameter
# ------------------------------------------
# sDTW
# ------------------------------------------
setupMdl['PM_sDTW_gamma'] = 0.5 # soft alignment parameter
# ------------------------------------------
# MVM
# ------------------------------------------
setupMdl['PM_MVM_steps'] = 10 # number of skipable steps
setupMdl['PM_MVM_metric'] = 'euclidean' # gak warping path metric 1) euclidean, 2) cityblock, 3) Kulback-Leibler
setupMdl['PM_MVM_const'] = 'none' # 1) none, 2) sakoechiba or 3) itakura
###################################################################################################################
# Source Separation Parameters
###################################################################################################################
# ------------------------------------------
# General
# ------------------------------------------
setupMdl['SS_Gen_lr'] = 1e-9 # learning rate
# ------------------------------------------
# NMF
# ------------------------------------------
# ------------------------------------------
# DSC
# ------------------------------------------
setupMdl['SS_DSC_n'] = 20 # model order
###################################################################################################################
# Features
###################################################################################################################
# ==============================================================================
# Statistical (input based)
# ==============================================================================
setupMdl['feat_roll']['EWMA'] = [0]
setupMdl['feat_roll']['EWMS'] = [0]
setupMdl['feat_roll']['diff'] = 1
# ==============================================================================
# Statistical (frame based)
# ==============================================================================
setupMdl['feat']['Mean'] = 0 # mean value
setupMdl['feat']['Std'] = 0 # standard deviation
setupMdl['feat']['RMS'] = 1 # rms value
setupMdl['feat']['Peak2Rms'] = 0 # peak to rms value
setupMdl['feat']['Median'] = 1 # median value
setupMdl['feat']['Min'] = 1 # minimum value
setupMdl['feat']['Max'] = 1 # maximum value
setupMdl['feat']['Per25'] = 1 # 25% percentile
setupMdl['feat']['Per75'] = 1 # 75% percentile
setupMdl['feat']['Energy'] = 0 # energy or sum
setupMdl['feat']['Var'] = 0 # variance
setupMdl['feat']['Range'] = 1 # range of values (max - min)
setupMdl['feat']['3rdMoment'] = 0 # 3rd statistical moment (skewness)
setupMdl['feat']['4thMoment'] = 0 # 4th statistical moment (kurtosis)
# ==============================================================================
# 2D Features (select only one -> check index manually to select correct data)
# ==============================================================================
setupMdl['feat2D']['PQ'] = 1 # 1) raw pq values are used (product for V and I as input) if 2) addition for P and Q as input
setupMdl['feat2D']['VI'] = 0 # 1) VI-Trajectory is used
setupMdl['feat2D']['REC'] = 0 # 1) Recurrent plot is used
setupMdl['feat2D']['GAF'] = 0 # 1) Gramian Angular Field is used
setupMdl['feat2D']['MKF'] = 0 # 1) Markov Transition Field is used
setupMdl['feat2D']['DFIA'] = 0 # 1) FFT amplitudes, 2) FFT phases, 3) Amplitudes, Phases, Absolute values
###################################################################################################################
# Return
###################################################################################################################
return setupMdl