Training Data
physXAI.preprocessing.training_data
Classes
TrainingDataGeneric
Bases: ABC
A generic container class to hold all data related to a machine learning model's lifecycle. This includes training, validation, and test datasets (as NumPy arrays), model predictions, evaluation metrics, training history, and training time.
Source code in physXAI/preprocessing/training_data.py
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 |
|
Attributes
X_train = None
instance-attribute
X_val = None
instance-attribute
X_test = None
instance-attribute
y_train = None
instance-attribute
y_val = None
instance-attribute
y_test = None
instance-attribute
y_train_pred = None
instance-attribute
y_val_pred = None
instance-attribute
y_test_pred = None
instance-attribute
file_path = None
instance-attribute
training_record = None
instance-attribute
training_time = None
instance-attribute
metrics = None
instance-attribute
columns = None
instance-attribute
X_train_single
abstractmethod
property
y_train_single
abstractmethod
property
X_val_single
abstractmethod
property
y_val_single
abstractmethod
property
X_test_single
abstractmethod
property
y_test_single
abstractmethod
property
y_train_pred_single
abstractmethod
property
y_val_pred_single
abstractmethod
property
y_test_pred_single
abstractmethod
property
Functions
__init__()
Source code in physXAI/preprocessing/training_data.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
add_training_record(data)
Stores the training history or record.
For Keras models, this is typically the History
object returned by model.fit()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
The training record data. |
required |
Source code in physXAI/preprocessing/training_data.py
35 36 37 38 39 40 41 42 43 |
|
add_predictions(y_train_pred: np.array, y_val_pred: np.array, y_test_pred: np.array)
Stores the model's predictions for the training, validation, and test sets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_train_pred
|
ndarray
|
Predictions on the training set. |
required |
y_val_pred
|
Optional[ndarray]
|
Predictions on the validation set. |
required |
y_test_pred
|
ndarray
|
Predictions on the test set. |
required |
Source code in physXAI/preprocessing/training_data.py
45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
add_metrics(metrics)
Stores the calculated evaluation metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metrics
|
The metrics object. |
required |
Source code in physXAI/preprocessing/training_data.py
59 60 61 62 63 64 65 66 67 |
|
add_training_time(time: float)
Stores the duration of the model training process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time
|
float
|
The training time in seconds. |
required |
Source code in physXAI/preprocessing/training_data.py
69 70 71 72 73 74 75 76 |
|
add_file_path(path: str)
Source code in physXAI/preprocessing/training_data.py
78 79 |
|
get_config() -> dict
abstractmethod
Source code in physXAI/preprocessing/training_data.py
81 82 83 |
|
TrainingData
Bases: TrainingDataGeneric
A container class to hold all data related to a single-step machine learning model's lifecycle. This includes training, validation, and test datasets (as NumPy arrays), model predictions, evaluation metrics, training history, and training time.
Source code in physXAI/preprocessing/training_data.py
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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
Attributes
X_train: np.ndarray = X_train
instance-attribute
X_val: np.ndarray = X_val
instance-attribute
X_test: np.ndarray = X_test
instance-attribute
y_train: np.ndarray = y_train
instance-attribute
y_val: np.ndarray = y_val
instance-attribute
y_test: np.ndarray = y_test
instance-attribute
columns: list[str] = columns
instance-attribute
X_train_single
property
y_train_single
property
X_val_single
property
y_val_single
property
X_test_single
property
y_test_single
property
y_train_pred_single
property
y_val_pred_single
property
y_test_pred_single
property
Functions
__init__(X_train: np.array, X_val: np.array, X_test: np.array, y_train: np.array, y_val: np.array, y_test: np.array, columns: list[str])
Initializes the TrainingData object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X_train
|
ndarray
|
NumPy array of training features. |
required |
X_val
|
Optional[ndarray]
|
NumPy array of validation features. Can be None. |
required |
X_test
|
ndarray
|
NumPy array of test features. |
required |
y_train
|
ndarray
|
NumPy array of training target values. |
required |
y_val
|
Optional[ndarray]
|
NumPy array of validation target values. Can be None. |
required |
y_test
|
ndarray
|
NumPy array of test target values. |
required |
columns
|
List[str]
|
List of input feature names (columns of X). |
required |
Source code in physXAI/preprocessing/training_data.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
get_config() -> dict
Source code in physXAI/preprocessing/training_data.py
163 164 165 166 167 168 169 170 |
|
TrainingDataMultiStep
Bases: TrainingDataGeneric
A container class for data related to multi-step forecasting models, typically using tf.data.Dataset objects for handling windowed sequence data. It also extracts NumPy array versions of these datasets for easier inspection or use with libraries that expect NumPy arrays.
Source code in physXAI/preprocessing/training_data.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
Attributes
train_ds = train_ds
instance-attribute
val_ds = val_ds
instance-attribute
test_ds = test_ds
instance-attribute
columns = columns
instance-attribute
output = output
instance-attribute
init_columns = init_columns
instance-attribute
X_val = None
instance-attribute
y_val = None
instance-attribute
single_step_metrics = None
instance-attribute
X_train_single
property
X_train_init
property
X_train_features
property
y_train_single
property
X_val_single
property
X_val_init
property
X_val_features
property
y_val_single
property
X_test_single
property
X_test_init
property
X_test_features
property
y_test_single
property
y_train_pred_single
property
y_val_pred_single
property
y_test_pred_single
property
Functions
__init__(train_ds, val_ds, test_ds, columns: list[str], output: list[str], init_columns: list[str])
Initializes the TrainingDataMultiStep object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
train_ds
|
Dataset
|
TensorFlow Dataset for training. Each element is typically a tuple (features, labels). Features can be a single tensor or a tuple (e.g., (main_input, warmup_input)). |
required |
val_ds
|
Optional[Dataset]
|
TensorFlow Dataset for validation. Can be None. |
required |
test_ds
|
Dataset
|
TensorFlow Dataset for testing. |
required |
columns
|
List[str]
|
List of input feature names (columns of X). |
required |
output
|
(str
|
(List of) Name(s) of the output column(s). |
required |
Source code in physXAI/preprocessing/training_data.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
add_single_step_metrics(metrics)
Stores the calculated evaluation single step metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metrics
|
The metrics object. |
required |
Source code in physXAI/preprocessing/training_data.py
251 252 253 254 255 256 257 258 259 |
|
get_config() -> dict
Source code in physXAI/preprocessing/training_data.py
320 321 322 323 324 325 326 327 |
|