API Reference¶
Folder Config/¶
add_lag_features(df, forecast_horizon, max_lag_day)
¶
Adds a lagged column to the dataframe based on the given horizon in minutes and max lag in days.
Args: df (pd.DataFrame): The input dataframe with a datetime index and a column 'y'. forecast_horizon (int): The horizon in minutes for the lag. max_lag_day (int): the number of days until the longest lag
Returns: pd.DataFrame: The dataframe with additional columns for the lags.
Source code in docs\notebooks\config\general_functions.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
compute_MAE(forecast, observation)
¶
As the name suggest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forecast
|
df
|
series of the forecast result from the model |
required |
observation
|
df
|
series of the observed value (actual value) |
required |
Returns:
| Type | Description |
|---|---|
|
error as the name suggest (float): as the name suggest |
Source code in docs\notebooks\config\general_functions.py
834 835 836 837 838 839 840 841 842 843 844 | |
compute_MAPE(forecast, observation)
¶
As the name suggest. Be careful with MAPE though because its value can go to inf since the observed value can be 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forecast
|
df
|
series of the forecast result from the model |
required |
observation
|
df
|
series of the observed value (actual value) |
required |
Returns:
| Type | Description |
|---|---|
|
error as the name suggest (float): as the name suggest |
Source code in docs\notebooks\config\general_functions.py
860 861 862 863 864 865 866 867 868 869 870 | |
compute_MASE(forecast, observation, train_result)
¶
As the name suggest. MASE is first introduced by Rob Hyndman, used to handle MAPE problem being infinity. Instead of using observed value as denominator, MASE uses MAE of the naive forecast at the train set for denominator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forecast
|
df
|
series of the forecast result from the model |
required |
observation
|
df
|
series of the observed value (actual value) |
required |
Returns:
| Type | Description |
|---|---|
|
error as the name suggest (float): as the name suggest |
Source code in docs\notebooks\config\general_functions.py
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 | |
compute_MBE(forecast, observation)
¶
As the name suggest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forecast
|
df
|
series of the forecast result from the model |
required |
observation
|
df
|
series of the observed value (actual value) |
required |
Returns:
| Type | Description |
|---|---|
|
error as the name suggest (float): as the name suggest |
Source code in docs\notebooks\config\general_functions.py
821 822 823 824 825 826 827 828 829 830 831 | |
compute_R2(forecast, observation)
¶
As the name suggest. Be careful with R2 though because it is not a forecast evaluation. It is just used to show linearity on the scatter plot of forecast and observed value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forecast
|
df
|
series of the forecast result from the model |
required |
observation
|
df
|
series of the observed value (actual value) |
required |
Returns:
| Type | Description |
|---|---|
|
error as the name suggest (float): as the name suggest |
Source code in docs\notebooks\config\general_functions.py
906 907 908 909 910 911 912 913 914 915 916 917 | |
compute_RMSE(forecast, observation)
¶
As the name suggest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forecast
|
df
|
series of the forecast result from the model |
required |
observation
|
df
|
series of the observed value (actual value) |
required |
Returns:
| Type | Description |
|---|---|
|
error as the name suggest (float): as the name suggest |
Source code in docs\notebooks\config\general_functions.py
847 848 849 850 851 852 853 854 855 856 857 | |
compute_exp_no(path_result)
¶
Compute experiment number for folder & file naming based on the number of existing experiments that have been done. For example, if on the folder there are already 5 experiment folders, then the new experiment no. is E00006.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_result
|
str
|
relative path of experiment folder, stored in config |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
exp no |
|
str |
exp no in str |
Source code in docs\notebooks\config\general_functions.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
compute_folder_name(experiment_no_str, forecast_horizon, model_name, hyperparameter_no)
¶
Folder name in the format of [exp number][exp date][dataset][forecast horizon][model]_[hyperparameter]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_no_str
|
str
|
exp number |
required |
forecast_horizon
|
int
|
forecast horizon in minutes |
required |
model_name
|
str
|
for example, m1_naive |
required |
hyperparameter_no
|
str
|
for example, hp1 |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
folder name |
Source code in docs\notebooks\config\general_functions.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
compute_fskill(forecast, observation, naive)
¶
As the name suggest. Forecast Skill is a relative measure seeing the improvement of the model performance over naive model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forecast
|
df
|
series of the forecast result from the model |
required |
observation
|
df
|
series of the observed value (actual value) |
required |
Returns:
| Type | Description |
|---|---|
|
error as the name suggest (float): as the name suggest |
Source code in docs\notebooks\config\general_functions.py
892 893 894 895 896 897 898 899 900 901 902 903 | |
export_result(filepath, df_a1_result, cross_val_result_df, hyperparameter)
¶
Export experiment summary: 1. experiment result 2. hyperparameter 3. cross validation detailed result
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
dict
|
dictionary of filepaths for exporting result |
required |
Source code in docs\notebooks\config\general_functions.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
histogram_residual(residual, df, pathname)
¶
Produce histogiram of residual value and save it on the designated folder
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
residual
|
df
|
forecast - observation |
required |
pathname
|
str
|
filepath to save the figure |
required |
Source code in docs\notebooks\config\general_functions.py
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 | |
input_and_process(path_data_cleaned, forecast_horizon, max_lag_day, n_block, hyperparameter)
¶
read dataset, add calendar features, add lag features (which depends on the forecast horizon).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_data_cleaned
|
str
|
path to the dataset chosen |
required |
forecast_horizon
|
int
|
forecast horizon in minutes |
required |
max_lag_day
|
int
|
how much lag data will be used, written in days. For example, 7 means lag data until d-7 is used. |
required |
n_block
|
int
|
number of blocks to divide the original df. This includes the block for hold_out_df, so if k=10, this n_block = k+1 = 11 |
required |
hyperparameter
|
dict
|
hyperparameters for the model |
required |
Returns:
| Name | Type | Description |
|---|---|---|
block_length |
int
|
number of weeks per block |
holdout_df |
df
|
unused df, can be used later for unbiased estimate of final model performance |
df |
df
|
df that will be used for training and validation (test) set |
Source code in docs\notebooks\config\general_functions.py
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 | |
prepare_directory(path_result, forecast_horizon, model_name, hyperparameter_no)
¶
Do two things, 1. Create folders inside the experiment result folder 2. Create some file names to be used when exporting result later
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_result
|
str
|
relative path to the experiment result folder |
required |
forecast_horizon
|
int
|
forecast horizon in minutes |
required |
model_name
|
str
|
eg m1_naive |
required |
hyperparameter_no
|
str
|
eg |
required |
Returns:
| Name | Type | Description |
|---|---|---|
hyperparameter |
df
|
pd df series of hyperparameter chosen |
|
experiment_no_str (str) : experiment number |
||
|
filepath (dict) : dict of all filepaths that will be exported |
Source code in docs\notebooks\config\general_functions.py
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 | |
produce_forecast(model_name, model, train_df_X, test_df_X, train_df_y, forecast_horizon)
¶
Generate forecasts based on the model and its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
string
|
Model identifier (e.g., 'm1_naive'). |
required |
model
|
dict
|
Trained model object containing all relevant features. |
required |
train_df_X
|
DataFrame
|
Matrix of predictors for training set. |
required |
test_df_X
|
DataFrame
|
Matrix of predictors for test set. |
required |
train_df_y
|
DataFrame
|
Target forecast y for training set. |
required |
forecast_horizon
|
int
|
Forecast horizon in minutes. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
train_df_y_hat |
DataFrame
|
Forecasted values for training set. |
test_df_y_hat |
DataFrame
|
Forecasted values for test set. |
Source code in docs\notebooks\config\general_functions.py
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | |
remove_jump_df(train_df_y)
¶
Remove jump in the time series data Parameters: train_df_y (pd.Series): Time series data
Returns:
| Name | Type | Description |
|---|---|---|
train_df_y_updated |
Series
|
Time series data with jump removed |
Source code in docs\notebooks\config\general_functions.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
run_experiment(dataset, forecast_horizon, model_name, hyperparameter_no)
¶
Run the experiment with the specified parameters. Args: dataset (str): Name of the dataset file. forecast_horizon (int): Forecast horizon in minutes. model_name (str): Model identifier (e.g., 'm6_lr'). hyperparameter_no (str): Hyperparameter set identifier.
Returns:
| Type | Description |
|---|---|
|
None. Results and models are saved to disk. |
Source code in docs\notebooks\config\general_functions.py
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 | |
run_model(df, model_name, hyperparameter, filepath, forecast_horizon, experiment_no_str, block_length)
¶
Run model! This will be updated so that it can adapt to any model This consists of 1. Loop over all CV, then inside the loop, 2. Split df to train and test set 3. Train model on train set 4. Produce naive forecast on both trian and test set for benchmark 5. Produce forecast on both train and test set 6. Compute residual on both train and test set 7. Export the observation, naive, forecast, and residual of train and test set 8. Produce plots only on CV 1 9. Evaluate forecast performance on train and test set 10. Quit the loop, 11. Summarise the overall performance of the model using RMSE and its Stddev 12. Export all results
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
df
|
df that will be used for training and validation (test) set, consists of X and Y |
required |
model_name
|
string
|
eg 'm06_lr' |
required |
hyperparameter
|
pd series
|
list of hyperparameter for that model |
required |
filepath
|
dict
|
dictionary of filepaths for exporting result |
required |
forecast_horizon
|
the forecast horizon |
required | |
experiment_no
|
the experiment no. in string |
required | |
block_length
|
block length of one cross validation set |
required |
Source code in docs\notebooks\config\general_functions.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 | |
save_model(filepath, cv_no, model)
¶
Export model into binary file using pickle to a designated file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
dictionary
|
dictionary of the file path |
required |
cv_no (int)
|
cv number |
required | |
model
|
dictionary
|
trained model |
required |
Source code in docs\notebooks\config\general_functions.py
588 589 590 591 592 593 594 595 596 597 598 599 | |
scatterplot_forecast(observation, forecast, R2, pathname)
¶
Produce scatterplot observation vs forecast value and save it on the designated folder
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observation
|
df
|
observed value |
required |
forecast
|
df
|
forecast value |
required |
pathname
|
str
|
filepath to save the figure |
required |
Source code in docs\notebooks\config\general_functions.py
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | |
separate_holdout(df, n_block)
¶
Separating df into two parts: 1. df : df that will be used for training and blocked k-fold cross validation. The block is a multiple of a week because net load data has weekly seasonality 2. hold_out_df : this section is not used for now, but can be useful for final test of the chosen model if wanted, to show the generalized error. This is at least 1 block of data.
By default, the chosen k for k-fold cross validation is 10.
For example, the original df has 12 weeks worth of data. In this case, new df is week 1-10, hold_out_df is week 11-12,
the new df will be used for cross validation, for example CV1: training: week 1-9, validation (test) week 10 CV2: training: week 1-8, week 10, validation (test) week 9, etc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
df
|
cleaned df consisting of y and all predictors |
required |
n_block
|
int
|
number of blocks to divide the original df. This includes the block for hold_out_df, so if k=10, this n_block = k+1 = 11 |
required |
Returns:
| Type | Description |
|---|---|
|
block_length (int) : number of weeks per block |
|
|
hodout_df (df) : unused df, can be used later for unbiased estimate of final model performance |
|
|
df (df) : df that will be used for training and validation (test) set |
Source code in docs\notebooks\config\general_functions.py
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 | |
split_time_series(df, cv_no)
¶
Split df to train and test set using blocked cross validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
df
|
df that will be used for training and validation (test) set, consists of X and Y |
required |
cv_no
|
int
|
number of current cv order. cv_no=1 means the test set is at the last, cv_no = k means the test set is at the beginning |
required |
Returns:
| Type | Description |
|---|---|
|
train_df (df) : df used for training |
|
|
test_df (df) : df used for validation, formal name is validation set / dev set. |
Source code in docs\notebooks\config\general_functions.py
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
split_xy(df)
¶
separate forecast target y and all predictors X into two dfs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
df
|
df containing the forecast target y and all predictors X |
required |
Return
df_X (df): df of all predictors X df_y (df): df of target forecast y
Source code in docs\notebooks\config\general_functions.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
timeplot_forecast(observation, forecast, pathname)
¶
Produce time plot of observation vs forecast value and save it on the designated folder
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observation
|
df
|
observed value |
required |
forecast
|
df
|
forecast value |
required |
pathname
|
str
|
filepath to save the figure |
required |
Source code in docs\notebooks\config\general_functions.py
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 | |
timeplot_residual(residual, pathname)
¶
Produce time plot of resodia; value and save it on the designated folder
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
residual
|
df
|
forecast - observation |
required |
pathname
|
str
|
filepath to save the figure |
required |
Source code in docs\notebooks\config\general_functions.py
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | |
train_model(model_name, hyperparameter, train_df_X, train_df_y, forecast_horizon)
¶
train model based on the model choice, hyperparamter, predictors X and target y
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
string
|
eg 'm06_lr' |
required |
hyperparameter
|
pd series
|
list of hyperparameter for that model |
required |
train_df_X
|
df
|
matrix of predictors |
required |
train_df_y
|
df
|
target forecast y |
required |
forecast_horizon
|
int
|
Forecast horizon in minutes. |
required |
Returns:
| Type | Description |
|---|---|
|
model (dict) : general object storing all models info including the predictor, feature selection, |
|
|
and all other relevant features |
Source code in docs\notebooks\config\general_functions.py
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
Folder Model/¶
produce_forecast_m1_naive(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m1_naive.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
train_model_m1_naive(hyperparameter, train_df_X, train_df_y)
¶
Train and test a naive model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m1_naive.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
produce_forecast_m2_snaive(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m2_snaive.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
train_model_m2_snaive(hyperparameter, train_df_X, train_df_y)
¶
Train and test a seasonal model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m2_snaive.py
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 | |
produce_forecast_m3_ets(model, train_df_X, test_df_X, forecast_horizon)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
forecast_horizon
|
int
|
forecast horizon in mins |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m3_ets.py
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 | |
train_model_m3_ets(hyperparameter, train_df_X, train_df_y, forecast_horizon)
¶
Train and test a linear model for point forecasting. https://www.statsmodels.org/dev/generated/statsmodels.tsa.statespace.exponential_smoothing.ExponentialSmoothing.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required | |
forecast_horizon (int)
|
forecast horizon in mins |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m3_ets.py
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 | |
produce_forecast_m4_arima(model, train_df_X, test_df_X, forecast_horizon)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
forecast_horizon
|
int
|
forecast horizon in mins |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m4_arima.py
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 | |
train_model_m4_arima(hyperparameter, train_df_X, train_df_y, forecast_horizon)
¶
Train and test a linear model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required | |
forecast_horizon (int)
|
forecast horizon in mins |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m4_arima.py
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 | |
produce_forecast_m5_sarima(model, train_df_X, test_df_X, forecast_horizon)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
forecast_horizon
|
int
|
forecast horizon in mins |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m5_sarima.py
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 | |
train_model_m5_sarima(hyperparameter, train_df_X, train_df_y, forecast_horizon)
¶
Train and test a linear model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required | |
forecast_horizon (int)
|
forecast horizon in mins |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m5_sarima.py
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 | |
produce_forecast_m6_lr(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m6_lr.py
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 | |
train_model_m6_lr(hyperparameter, train_df_X, train_df_y)
¶
Train and test a linear model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (dictionary) : trained model with all features |
Source code in docs\notebooks\model\m6_lr.py
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 | |
produce_forecast_m7_ann(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m7_ann.py
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 | |
train_model_m7_ann(hyperparameter, train_df_X, train_df_y)
¶
Train and test a linear model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m7_ann.py
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 | |
produce_forecast_m8_dnn(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dict
|
all parameters of the trained model |
required |
train_df_X
|
DataFrame
|
predictors of train set |
required |
test_df_X
|
DataFrame
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (DataFrame) : forecast result at train set |
|
|
test_df_y_hat (DataFrame) : forecast result at test set |
Source code in docs\notebooks\model\m8_dnn.py
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 | |
train_model_m8_dnn(hyperparameter, train_df_X, train_df_y)
¶
Train and test a linear model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (dict)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (DataFrame)
|
features matrix for training |
required | |
train_df_y (DataFrame)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (dict) : trained model with all features |
Source code in docs\notebooks\model\m8_dnn.py
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 | |
produce_forecast_m9_rt(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m9_rt.py
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 | |
train_model_m9_rt(hyperparameter, train_df_X, train_df_y)
¶
Train and test a regression tree model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m9_rt.py
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 | |
produce_forecast_m10_rf(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m10_rf.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
train_model_m10_rf(hyperparameter, train_df_X, train_df_y)
¶
Train and test a random forest model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m10_rf.py
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 | |
produce_forecast_m11_svr(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m11_svr.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
train_model_m11_svr(hyperparameter, train_df_X, train_df_y)
¶
Train and test a linear model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m11_svr.py
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 | |
produce_forecast_m12_rnn(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained RNN model
Source code in docs\notebooks\model\m12_rnn.py
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 | |
separate_lag_and_exogenous_features(train_df_X, target_column='y', lag_prefix='y_lag')
¶
This function separates the lag features and exogenous variables from the training dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
train_df_X
|
DataFrame
|
The dataframe containing both lag features and exogenous variables. |
required |
target_column
|
str
|
The name of the target column (e.g., 'y'). |
'y'
|
lag_prefix
|
str
|
The prefix used for lag columns (e.g., 'y_lag'). |
'y_lag'
|
Returns:
| Name | Type | Description |
|---|---|---|
X_lags |
DataFrame
|
DataFrame containing only the lag features. |
X_exog |
DataFrame
|
DataFrame containing only the exogenous variables. |
Source code in docs\notebooks\model\m12_rnn.py
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 | |
train_model_m12_rnn(hyperparameter, train_df_X, train_df_y)
¶
Train and test an RNN model for point forecasting. Essentially we use the RNN block to learn the temporal patterns of the time series, and then use a fully connected layer to learn the relationship between the lag features. We take the last hidden state of the RNN as the output, and concatenate it with the exogenous features (like calendar) to make the final prediction using a fully connected layer.
Source code in docs\notebooks\model\m12_rnn.py
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 | |
produce_forecast_m13_lstm(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m13_lstm.py
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 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
separate_lag_and_exogenous_features(train_df_X, target_column='y', lag_prefix='y_lag')
¶
This function separates the lag features and exogenous variables from the training dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
train_df_X
|
DataFrame
|
The dataframe containing both lag features and exogenous variables. |
required |
target_column
|
str
|
The name of the target column (e.g., 'y'). |
'y'
|
lag_prefix
|
str
|
The prefix used for lag columns (e.g., 'y_lag'). |
'y_lag'
|
Returns:
| Name | Type | Description |
|---|---|---|
X_lags |
DataFrame
|
DataFrame containing only the lag features. |
X_exog |
DataFrame
|
DataFrame containing only the exogenous variables. |
Source code in docs\notebooks\model\m13_lstm.py
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 | |
train_model_m13_lstm(hyperparameter, train_df_X, train_df_y)
¶
Train and test an LSTM model for point forecasting. Essentially we use the LSTM block to learn the temporal patterns of the time series, and then use a fully connected layer to learn the relationship between the lag features. We take the last hidden state of the LSTM as the output, and concatenate it with the exogenous features (like calendar) to make the final prediction using a fully connected layer. Future imporvement maybe to improve the architecture of the fully connected layer after LSTM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m13_lstm.py
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 | |
produce_forecast_m14_gru(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained GRU model Args: model (dictionary): all parameters of the trained model train_df_X (df): predictors of train set test_df_X (df): predictors of test set
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m14_gru.py
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 | |
train_model_m14_gru(hyperparameter, train_df_X, train_df_y)
¶
Train and test a GRU model for point forecasting. Uses GRU for temporal patterns, FC layer for lag+exogenous features. Args: hyperparameter (df) : hyperparameter value of the model consisting of number of features train_df_X (df) : features matrix for training train_df_y (df) : target matrix for training
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m14_gru.py
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 | |
produce_forecast_m15_transformer(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained Transformer model Args: model (dictionary): all parameters of the trained model train_df_X (df): predictors of train set test_df_X (df): predictors of test set
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m15_transformer.py
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 | |
train_model_m15_transformer(hyperparameter, train_df_X, train_df_y)
¶
Train and test a Transformer model for point forecasting. Uses Transformer for temporal patterns, FC layer for lag+exogenous features. Args: hyperparameter (df) : hyperparameter value of the model consisting of number of features train_df_X (df) : features matrix for training train_df_y (df) : target matrix for training
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m15_transformer.py
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 | |
produce_forecast_m16_prophet(model, train_df_X, test_df_X, train_df_y, forecast_horizon)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
train_df_y
|
df
|
target of train set |
required |
forecast_horizon
|
int
|
forecast horizon for the model |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m16_prophet.py
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 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 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
train_model_m16_prophet(hyperparameter, train_df_X, train_df_y, forecast_horizon)
¶
Train a prophet model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required | |
forecast_horizon (int)
|
forecast horizon for the model |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m16_prophet.py
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 | |
produce_forecast_m17_xgb(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
dictionary
|
all parameters of the trained model |
required |
train_df_X
|
df
|
predictors of train set |
required |
test_df_X
|
df
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (df) : forecast result at train set |
|
|
test_df_y_hat (df) : forecast result at test set |
Source code in docs\notebooks\model\m17_xgb.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
train_model_m17_xgb(hyperparameter, train_df_X, train_df_y)
¶
Train and test a xgb model for point forecasting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (df)
|
hyperparameter value of the model consisting of number of features |
required | |
train_df_X (df)
|
features matrix for training |
required | |
train_df_y (df)
|
target matrix for training |
required |
Returns:
| Type | Description |
|---|---|
|
model (model) : trained model with all features |
Source code in docs\notebooks\model\m17_xgb.py
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 | |
produce_forecast_m18_nbeats(model, train_df_X, test_df_X)
¶
Create forecast at the train and test set using the trained NBeats model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
trained NBeats PyTorch model |
required | |
train_df_X (DataFrame)
|
predictors of train set |
required | |
test_df_X (DataFrame)
|
predictors of test set |
required |
Returns:
| Type | Description |
|---|---|
|
train_df_y_hat (DataFrame) : forecast result at train set |
|
|
test_df_y_hat (DataFrame) : forecast result at test set |
Source code in docs\notebooks\model\m18_nbeats.py
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 | |
train_model_m18_nbeats(hyperparameter, train_df_X, train_df_y)
¶
Train and test an NBeats model for point forecasting. Uses NBeats architecture for predicting time series with lag+exogenous features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameter (dict)
|
model hyperparameters |
required | |
train_df_X (DataFrame)
|
predictors for training |
required | |
train_df_y (DataFrame)
|
target for training |
required |
Returns:
| Name | Type | Description |
|---|---|---|
model |
trained PyTorch NBeats model |
Source code in docs\notebooks\model\m18_nbeats.py
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 | |