File size: 58,420 Bytes
4025ff4
 
ea4ecaf
 
 
 
d988e19
74e9e3e
 
 
 
 
 
5e93f20
ea4ecaf
 
 
 
 
 
5e93f20
 
 
 
4fc9f07
 
 
5e93f20
4fc9f07
 
5e93f20
 
d988e19
ea4ecaf
 
5b822b6
 
8145b83
5b822b6
adff9d4
 
 
 
 
b47dba5
 
45b89de
adff9d4
 
 
0974d3a
adff9d4
 
0974d3a
5e93f20
1f6629c
72e66c8
0974d3a
72e66c8
adff9d4
 
5e93f20
 
8145b83
5e93f20
 
 
d988e19
4025ff4
4fc9f07
 
 
d988e19
4025ff4
 
66accd2
 
 
 
5e93f20
66accd2
5e93f20
66accd2
d988e19
 
 
 
66accd2
 
4025ff4
4fc9f07
4025ff4
ea4ecaf
5e93f20
 
4025ff4
 
 
 
d988e19
4025ff4
8ade2e2
4025ff4
0974d3a
d988e19
f62fe9f
72e66c8
 
 
d988e19
72e66c8
edc01aa
 
 
 
d988e19
4025ff4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72e66c8
1f6629c
72e66c8
1f6629c
72e66c8
4025ff4
 
 
 
 
30e4480
72e66c8
 
1f6629c
72e66c8
1f00acb
 
 
30e4480
72e66c8
 
1f6629c
72e66c8
4025ff4
 
1f00acb
30e4480
72e66c8
 
1f6629c
72e66c8
4025ff4
 
1f00acb
30e4480
72e66c8
 
1f6629c
72e66c8
4025ff4
 
1f00acb
30e4480
72e66c8
 
1f6629c
72e66c8
4025ff4
 
 
 
 
 
1f6629c
 
 
 
 
 
4025ff4
 
d988e19
4025ff4
 
 
 
 
0974d3a
72e66c8
4025ff4
 
 
 
d988e19
ea4ecaf
72e66c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f6629c
72e66c8
1f6629c
72e66c8
 
 
 
 
8145b83
 
 
 
1f6629c
a130c8d
72e66c8
 
8145b83
 
 
 
1f6629c
a130c8d
72e66c8
 
8145b83
 
 
 
1f6629c
a130c8d
72e66c8
 
8145b83
 
 
 
1f6629c
a130c8d
72e66c8
 
8145b83
 
 
 
1f6629c
a130c8d
72e66c8
 
 
 
 
 
1f6629c
8145b83
 
 
 
 
1f6629c
 
a130c8d
 
 
 
 
72e66c8
 
d988e19
72e66c8
 
 
 
ea4ecaf
0974d3a
72e66c8
ea4ecaf
 
 
 
d988e19
4025ff4
72e66c8
 
 
 
 
 
8145b83
1f6629c
72e66c8
 
8145b83
 
 
 
 
66accd2
8145b83
72e66c8
 
 
edc01aa
5e93f20
72e66c8
edc01aa
 
4fc9f07
72e66c8
4fc9f07
edc01aa
72e66c8
0974d3a
edc01aa
 
 
72e66c8
edc01aa
 
0974d3a
edc01aa
 
 
 
d988e19
faea8e4
 
 
0974d3a
d988e19
f62fe9f
0974d3a
72e66c8
d988e19
72e66c8
faea8e4
 
 
 
d988e19
edc01aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72e66c8
1f6629c
edc01aa
1f6629c
edc01aa
 
 
 
 
 
 
 
 
 
 
 
 
 
30e4480
faea8e4
1f6629c
 
edc01aa
72e66c8
edc01aa
 
 
72e66c8
 
edc01aa
 
 
 
 
30e4480
faea8e4
1f6629c
 
edc01aa
72e66c8
edc01aa
 
 
72e66c8
 
edc01aa
 
 
 
 
30e4480
faea8e4
1f6629c
 
edc01aa
72e66c8
edc01aa
 
 
72e66c8
 
edc01aa
 
 
 
 
30e4480
faea8e4
1f6629c
 
edc01aa
72e66c8
edc01aa
 
 
72e66c8
 
edc01aa
 
 
 
 
30e4480
faea8e4
1f6629c
 
edc01aa
72e66c8
edc01aa
 
 
72e66c8
 
edc01aa
 
 
 
 
 
 
 
1f6629c
 
 
 
 
 
edc01aa
72e66c8
 
 
 
 
 
edc01aa
72e66c8
 
 
 
 
 
edc01aa
 
d988e19
edc01aa
 
 
 
ea4ecaf
0974d3a
72e66c8
ea4ecaf
 
edc01aa
e5f0117
d988e19
edc01aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72e66c8
1f6629c
72e66c8
1f6629c
72e66c8
 
 
 
 
 
 
 
 
 
 
 
 
8145b83
 
 
 
1f6629c
8145b83
 
f62fe9f
840b77e
 
5e93f20
8145b83
 
 
72e66c8
 
8145b83
 
 
 
1f6629c
8145b83
 
226c394
 
5e93f20
8145b83
 
 
 
72e66c8
 
8145b83
 
 
 
1f6629c
8145b83
 
226c394
 
5e93f20
8145b83
 
 
 
72e66c8
 
8145b83
 
 
 
1f6629c
8145b83
 
226c394
 
 
8145b83
 
 
 
72e66c8
 
8145b83
 
 
 
1f6629c
8145b83
 
226c394
 
 
8145b83
 
 
 
72e66c8
 
 
 
 
 
1f6629c
8145b83
 
 
 
 
72e66c8
 
8145b83
 
 
 
 
72e66c8
 
8145b83
 
 
 
 
72e66c8
 
d988e19
72e66c8
 
 
 
 
0974d3a
72e66c8
 
 
 
 
d988e19
72e66c8
 
 
 
 
 
 
8145b83
1f6629c
72e66c8
 
8145b83
 
 
 
 
 
 
 
 
 
 
 
 
66accd2
 
72e66c8
 
 
 
5e93f20
72e66c8
 
 
54e965b
0974d3a
54e965b
30e4480
66accd2
d988e19
30e4480
 
 
 
d988e19
72e66c8
 
 
0974d3a
 
72e66c8
 
 
 
 
 
d988e19
72e66c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f6629c
edc01aa
1f6629c
e5f0117
 
 
 
 
 
 
 
 
edc01aa
 
 
 
 
8145b83
 
 
1f6629c
8145b83
 
 
 
1f6629c
8145b83
5e93f20
8145b83
 
edc01aa
 
 
8145b83
 
 
1f6629c
8145b83
 
f62fe9f
 
1f6629c
5e93f20
8145b83
 
 
edc01aa
 
 
8145b83
 
 
1f6629c
8145b83
 
f62fe9f
 
66accd2
5e93f20
8145b83
 
 
edc01aa
 
 
8145b83
 
 
226c394
8145b83
 
1f6629c
66accd2
 
5e93f20
8145b83
 
 
edc01aa
 
 
8145b83
 
 
1f6629c
8145b83
 
54e965b
0974d3a
 
5e93f20
 
8145b83
 
72e66c8
 
 
 
 
 
1f6629c
8145b83
 
 
 
 
72e66c8
 
8145b83
 
 
 
 
72e66c8
 
8145b83
 
 
 
 
72e66c8
 
d988e19
72e66c8
 
 
 
 
5e93f20
72e66c8
 
 
 
 
d988e19
72e66c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f6629c
72e66c8
1f6629c
72e66c8
 
 
 
 
 
 
 
 
 
 
 
 
30e4480
8145b83
 
 
1f6629c
b47dba5
 
66accd2
 
 
b47dba5
 
 
 
72e66c8
 
30e4480
8145b83
 
 
1f6629c
b47dba5
 
66accd2
 
 
b47dba5
 
 
 
72e66c8
 
30e4480
8145b83
 
 
1f6629c
b47dba5
 
66accd2
 
 
b47dba5
 
 
 
72e66c8
 
30e4480
8145b83
 
 
1f6629c
b47dba5
 
66accd2
 
8145b83
b47dba5
 
 
 
72e66c8
 
30e4480
8145b83
 
 
1f6629c
b47dba5
 
66accd2
 
 
b47dba5
 
 
 
edc01aa
 
 
 
 
 
1f6629c
b47dba5
 
 
 
 
e5f0117
72e66c8
b47dba5
 
 
 
 
edc01aa
72e66c8
b47dba5
 
 
 
 
edc01aa
 
d988e19
edc01aa
 
 
 
e5f0117
5e93f20
72e66c8
 
 
 
 
d988e19
72e66c8
 
 
 
 
 
 
30e4480
1f6629c
72e66c8
 
30e4480
1f6629c
 
66accd2
1f6629c
 
 
 
 
 
 
 
 
66accd2
 
72e66c8
 
 
 
5e93f20
72e66c8
e5f0117
 
 
 
 
 
0974d3a
d988e19
e5f0117
 
 
 
d988e19
e5f0117
fa08585
 
5e93f20
66accd2
fa08585
 
 
 
d988e19
fa08585
adff9d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9162fb4
1f6629c
 
9162fb4
66accd2
adff9d4
 
 
 
 
 
1f6629c
 
 
9162fb4
66accd2
adff9d4
 
 
 
1f6629c
9162fb4
1f6629c
9162fb4
66accd2
adff9d4
 
 
 
1f6629c
9162fb4
1f6629c
9162fb4
66accd2
adff9d4
 
 
 
1f6629c
9162fb4
1f6629c
9162fb4
66accd2
adff9d4
 
 
 
1f6629c
9162fb4
1f6629c
9162fb4
66accd2
adff9d4
 
 
 
 
 
66accd2
 
 
 
 
 
adff9d4
 
d988e19
adff9d4
 
 
 
fa08585
5e93f20
72e66c8
ea4ecaf
 
 
 
d988e19
72e66c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9162fb4
1f6629c
 
9162fb4
66accd2
72e66c8
 
 
 
 
 
1f6629c
9162fb4
1f6629c
9162fb4
66accd2
72e66c8
 
 
 
1f6629c
9162fb4
1f6629c
9162fb4
66accd2
72e66c8
 
 
 
1f6629c
9162fb4
1f6629c
9162fb4
66accd2
72e66c8
 
 
 
1f6629c
9162fb4
1f6629c
9162fb4
66accd2
72e66c8
 
 
 
1f6629c
9162fb4
1f6629c
9162fb4
66accd2
72e66c8
 
 
 
 
 
66accd2
 
 
 
 
 
72e66c8
 
d988e19
72e66c8
 
 
 
 
5e93f20
72e66c8
 
 
1f6629c
 
d988e19
1f6629c
 
 
 
 
 
 
 
9162fb4
 
 
 
66accd2
 
 
 
 
 
 
1f6629c
 
 
 
5e93f20
4f67208
 
 
8ade2e2
 
 
 
 
 
 
 
 
 
 
b47dba5
8ade2e2
b47dba5
 
 
 
 
 
 
 
 
 
 
 
8ade2e2
d988e19
8ade2e2
 
d988e19
8ade2e2
 
 
 
 
 
 
 
 
 
 
 
 
 
5e93f20
8ade2e2
d988e19
8ade2e2
 
5e93f20
8ade2e2
 
 
 
 
 
b47dba5
8ade2e2
 
 
1f6629c
 
 
8ade2e2
1f6629c
 
8ade2e2
1f6629c
8ade2e2
 
 
 
 
 
 
 
 
 
 
 
b47dba5
8ade2e2
b47dba5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ade2e2
1f6629c
 
8ade2e2
 
 
 
4f67208
 
f62fe9f
4f67208
 
 
 
b47dba5
ea4ecaf
88359f7
ea4ecaf
1f6629c
 
5e93f20
1f6629c
 
5e93f20
1f6629c
4f67208
 
0974d3a
1f6629c
 
4f67208
 
 
 
 
 
66accd2
ea4ecaf
 
 
 
b47dba5
72e66c8
 
 
1f6629c
 
 
72e66c8
1f6629c
 
 
d988e19
72e66c8
 
 
 
 
b47dba5
72e66c8
b47dba5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72e66c8
1f6629c
 
72e66c8
 
 
 
b47dba5
72e66c8
 
 
1f6629c
 
 
 
 
5e93f20
1f6629c
 
 
 
 
 
 
 
 
72e66c8
 
0974d3a
1f6629c
 
72e66c8
 
 
 
b47dba5
edc01aa
 
 
1f6629c
 
795bc0f
 
 
edc01aa
d988e19
edc01aa
 
 
 
 
b47dba5
4f67208
b47dba5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4f67208
5e93f20
1f6629c
4f67208
 
 
 
b47dba5
4f67208
 
 
1f6629c
 
4f67208
1f6629c
 
5e93f20
4f67208
 
0974d3a
1f6629c
 
edc01aa
 
4025ff4
4fc9f07
4025ff4
4fc9f07
 
 
 
0974d3a
4fc9f07
4025ff4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b47dba5
4025ff4
 
 
 
 
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
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
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
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
520
521
522
523
524
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
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
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
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
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
984
985
986
987
988
989
990
991
992
993
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
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
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
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
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
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# <span style=\"font-width:bold; font-size: 3rem; color:#2656a3;\">**Msc. BDS Module - Data Engineering and Machine Learning Operations in Business (MLOPs)** </span> <span style=\"font-width:bold; font-size: 3rem; color:#333;\">- Part 01: Feature Backfill</span>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The project uses [Hopsworks](https://www.hopsworks.ai) as the platform to store features in the **Hopworks Feature Store** and save a trained model in **Hopworks Model Registry**."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## <span style='color:#2656a3'> πŸ—’οΈ The notebook is divided into the following sections:\n",
    "1. Loading the data and process features.\n",
    "2. Connecting to Hopsworks Feature Store.\n",
    "3. Creating feature groups and uploading them to the feature store."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## <span style='color:#2656a3'> βš™οΈ Import of Libraries and Packages\n",
    "\n",
    "We start by accessing the folder we have created that holds the functions (incl. live API calls and data preprocessing) we need for electricity prices, weather measures, and the Danish calendar. Then, we proceed to import some of the necessary libraries and warnings to avoid unnecessary distractions and keep output clean."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/Users/camillahannesbo/Documents/AAU/Master - BDS/2. semester/Data Engineering and Machine learning operations in Business/MLOPs-Assignment-\n",
      "/Users/camillahannesbo/Documents/AAU/Master - BDS/2. semester/Data Engineering and Machine learning operations in Business/MLOPs-Assignment-/notebooks\n"
     ]
    }
   ],
   "source": [
    "# First we go one back in our directory to access the folder with our functions\n",
    "%cd ..\n",
    "\n",
    "# Now we import the functions from the features folder\n",
    "# This is the functions we have created to generate features for electricity prices, weather measures, and the danish calendar\n",
    "from features import electricity_prices, weather_measures, calendar\n",
    "\n",
    "# We go back into the notebooks folder\n",
    "%cd notebooks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Importing pandas for data handling\n",
    "import pandas as pd\n",
    "\n",
    "# Ignore warnings\n",
    "import warnings \n",
    "warnings.filterwarnings('ignore')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## <span style=\"color:#2656a3;\"> πŸ’½ Loading the Historical Data\n",
    "\n",
    "The data used comes from the following different sources:\n",
    "\n",
    "- Hourly electricity prices in Denmark per day on price area DK1 from [Energinet](https://www.energidataservice.dk).  Located in the folder folder `features/electricity_prices`.\n",
    "- Different meteorological observations based on Aalborg Denmark from [Open Meteo](https://www.open-meteo.com). Located in the folder `features/weather_measures`.\n",
    "- Weather Forecast based on Aalborg Denmark from [Open Meteo](https://www.open-meteo.com). Located in the folder `features/weather_measures`. (This data is used later to parse new real-time weather data)\n",
    "- Danish calendar that categorizes dates into types based on whether it is a weekday or not. This file is made manually by the group and is located in the folder `data` inside this repository.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### <span style=\"color:#2656a3;\">πŸ’Έ Electricity Prices per day from Energinet\n",
    "The first dataset we load is hourly electricity prices per day from Energinet/Dataservice."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Fetching historical electricity prices for area DK1 from January 1, 2022\n",
    "# Note: The end date is currently left out to retrieve data up to the day before present date \n",
    "# Today is not included in the data as it is not historical data\n",
    "electricity_df = electricity_prices.electricity_prices(\n",
    "    historical=True, \n",
    "    area=[\"DK1\"], \n",
    "    start='2022-01-01'\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>timestamp</th>\n",
       "      <th>datetime</th>\n",
       "      <th>date</th>\n",
       "      <th>hour</th>\n",
       "      <th>dk1_spotpricedkk_kwh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1640995200000</td>\n",
       "      <td>2022-01-01 00:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>0</td>\n",
       "      <td>0.37220</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1640998800000</td>\n",
       "      <td>2022-01-01 01:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>1</td>\n",
       "      <td>0.30735</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1641002400000</td>\n",
       "      <td>2022-01-01 02:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>2</td>\n",
       "      <td>0.32141</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1641006000000</td>\n",
       "      <td>2022-01-01 03:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>3</td>\n",
       "      <td>0.33806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1641009600000</td>\n",
       "      <td>2022-01-01 04:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>4</td>\n",
       "      <td>0.28013</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       timestamp            datetime        date  hour  dk1_spotpricedkk_kwh\n",
       "0  1640995200000 2022-01-01 00:00:00  2022-01-01     0               0.37220\n",
       "1  1640998800000 2022-01-01 01:00:00  2022-01-01     1               0.30735\n",
       "2  1641002400000 2022-01-01 02:00:00  2022-01-01     2               0.32141\n",
       "3  1641006000000 2022-01-01 03:00:00  2022-01-01     3               0.33806\n",
       "4  1641009600000 2022-01-01 04:00:00  2022-01-01     4               0.28013"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Display the first 5 rows of the electricity dataframe\n",
    "electricity_df.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>timestamp</th>\n",
       "      <th>datetime</th>\n",
       "      <th>date</th>\n",
       "      <th>hour</th>\n",
       "      <th>dk1_spotpricedkk_kwh</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20536</th>\n",
       "      <td>1714935600000</td>\n",
       "      <td>2024-05-05 19:00:00</td>\n",
       "      <td>2024-05-05</td>\n",
       "      <td>19</td>\n",
       "      <td>0.71783</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20537</th>\n",
       "      <td>1714939200000</td>\n",
       "      <td>2024-05-05 20:00:00</td>\n",
       "      <td>2024-05-05</td>\n",
       "      <td>20</td>\n",
       "      <td>0.83478</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20538</th>\n",
       "      <td>1714942800000</td>\n",
       "      <td>2024-05-05 21:00:00</td>\n",
       "      <td>2024-05-05</td>\n",
       "      <td>21</td>\n",
       "      <td>0.80204</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20539</th>\n",
       "      <td>1714946400000</td>\n",
       "      <td>2024-05-05 22:00:00</td>\n",
       "      <td>2024-05-05</td>\n",
       "      <td>22</td>\n",
       "      <td>0.73647</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20540</th>\n",
       "      <td>1714950000000</td>\n",
       "      <td>2024-05-05 23:00:00</td>\n",
       "      <td>2024-05-05</td>\n",
       "      <td>23</td>\n",
       "      <td>0.66136</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           timestamp            datetime        date  hour  \\\n",
       "20536  1714935600000 2024-05-05 19:00:00  2024-05-05    19   \n",
       "20537  1714939200000 2024-05-05 20:00:00  2024-05-05    20   \n",
       "20538  1714942800000 2024-05-05 21:00:00  2024-05-05    21   \n",
       "20539  1714946400000 2024-05-05 22:00:00  2024-05-05    22   \n",
       "20540  1714950000000 2024-05-05 23:00:00  2024-05-05    23   \n",
       "\n",
       "       dk1_spotpricedkk_kwh  \n",
       "20536               0.71783  \n",
       "20537               0.83478  \n",
       "20538               0.80204  \n",
       "20539               0.73647  \n",
       "20540               0.66136  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Display the last 5 rows of the electricity dataframe\n",
    "electricity_df.tail(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 20541 entries, 0 to 20540\n",
      "Data columns (total 5 columns):\n",
      " #   Column                Non-Null Count  Dtype         \n",
      "---  ------                --------------  -----         \n",
      " 0   timestamp             20541 non-null  int64         \n",
      " 1   datetime              20541 non-null  datetime64[ns]\n",
      " 2   date                  20541 non-null  object        \n",
      " 3   hour                  20541 non-null  int64         \n",
      " 4   dk1_spotpricedkk_kwh  20541 non-null  float64       \n",
      "dtypes: datetime64[ns](1), float64(1), int64(2), object(1)\n",
      "memory usage: 802.5+ KB\n"
     ]
    }
   ],
   "source": [
    "# Show the information for the electricity dataframe\n",
    "electricity_df.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### <span style=\"color:#2656a3;\"> 🌀 Weather measurements from Open Meteo\n",
    "Next weather measurements from Open Meteo is fetched."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### <span style=\"color:#2656a3;\"> πŸ•°οΈ Historical Weather Measures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Fetching historical weather measurements from January 1, 2022\n",
    "# Note: The end date is currently left out to retrieve data up to the day before present date \n",
    "# Today is not included in the data as it is not historical data\n",
    "historical_weather_df = weather_measures.historical_weather_measures(\n",
    "    historical=True, \n",
    "    start = '2022-01-01'\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>timestamp</th>\n",
       "      <th>datetime</th>\n",
       "      <th>date</th>\n",
       "      <th>hour</th>\n",
       "      <th>temperature_2m</th>\n",
       "      <th>relative_humidity_2m</th>\n",
       "      <th>precipitation</th>\n",
       "      <th>rain</th>\n",
       "      <th>snowfall</th>\n",
       "      <th>weather_code</th>\n",
       "      <th>cloud_cover</th>\n",
       "      <th>wind_speed_10m</th>\n",
       "      <th>wind_gusts_10m</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1640995200000</td>\n",
       "      <td>2022-01-01 00:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>0</td>\n",
       "      <td>6.7</td>\n",
       "      <td>100.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>16.2</td>\n",
       "      <td>36.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1640998800000</td>\n",
       "      <td>2022-01-01 01:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>1</td>\n",
       "      <td>6.6</td>\n",
       "      <td>100.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>16.2</td>\n",
       "      <td>30.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1641002400000</td>\n",
       "      <td>2022-01-01 02:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>2</td>\n",
       "      <td>6.7</td>\n",
       "      <td>99.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>15.5</td>\n",
       "      <td>30.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1641006000000</td>\n",
       "      <td>2022-01-01 03:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>3</td>\n",
       "      <td>6.7</td>\n",
       "      <td>100.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>12.7</td>\n",
       "      <td>28.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1641009600000</td>\n",
       "      <td>2022-01-01 04:00:00</td>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>4</td>\n",
       "      <td>6.7</td>\n",
       "      <td>99.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>10.6</td>\n",
       "      <td>23.8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       timestamp            datetime        date  hour  temperature_2m  \\\n",
       "0  1640995200000 2022-01-01 00:00:00  2022-01-01     0             6.7   \n",
       "1  1640998800000 2022-01-01 01:00:00  2022-01-01     1             6.6   \n",
       "2  1641002400000 2022-01-01 02:00:00  2022-01-01     2             6.7   \n",
       "3  1641006000000 2022-01-01 03:00:00  2022-01-01     3             6.7   \n",
       "4  1641009600000 2022-01-01 04:00:00  2022-01-01     4             6.7   \n",
       "\n",
       "   relative_humidity_2m  precipitation  rain  snowfall  weather_code  \\\n",
       "0                 100.0            0.0   0.0       0.0           3.0   \n",
       "1                 100.0            0.0   0.0       0.0           3.0   \n",
       "2                  99.0            0.0   0.0       0.0           3.0   \n",
       "3                 100.0            0.0   0.0       0.0           3.0   \n",
       "4                  99.0            0.0   0.0       0.0           3.0   \n",
       "\n",
       "   cloud_cover  wind_speed_10m  wind_gusts_10m  \n",
       "0        100.0            16.2            36.0  \n",
       "1        100.0            16.2            30.2  \n",
       "2        100.0            15.5            30.6  \n",
       "3        100.0            12.7            28.8  \n",
       "4        100.0            10.6            23.8  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Display the first 5 rows of the weather dataframe\n",
    "historical_weather_df.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>timestamp</th>\n",
       "      <th>datetime</th>\n",
       "      <th>date</th>\n",
       "      <th>hour</th>\n",
       "      <th>temperature_2m</th>\n",
       "      <th>relative_humidity_2m</th>\n",
       "      <th>precipitation</th>\n",
       "      <th>rain</th>\n",
       "      <th>snowfall</th>\n",
       "      <th>weather_code</th>\n",
       "      <th>cloud_cover</th>\n",
       "      <th>wind_speed_10m</th>\n",
       "      <th>wind_gusts_10m</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20515</th>\n",
       "      <td>1714849200000</td>\n",
       "      <td>2024-05-04 19:00:00</td>\n",
       "      <td>2024-05-04</td>\n",
       "      <td>19</td>\n",
       "      <td>12.2</td>\n",
       "      <td>88.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>4.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20516</th>\n",
       "      <td>1714852800000</td>\n",
       "      <td>2024-05-04 20:00:00</td>\n",
       "      <td>2024-05-04</td>\n",
       "      <td>20</td>\n",
       "      <td>11.4</td>\n",
       "      <td>92.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>70.0</td>\n",
       "      <td>1.5</td>\n",
       "      <td>2.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20517</th>\n",
       "      <td>1714856400000</td>\n",
       "      <td>2024-05-04 21:00:00</td>\n",
       "      <td>2024-05-04</td>\n",
       "      <td>21</td>\n",
       "      <td>10.7</td>\n",
       "      <td>96.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>64.0</td>\n",
       "      <td>0.4</td>\n",
       "      <td>2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20518</th>\n",
       "      <td>1714860000000</td>\n",
       "      <td>2024-05-04 22:00:00</td>\n",
       "      <td>2024-05-04</td>\n",
       "      <td>22</td>\n",
       "      <td>10.1</td>\n",
       "      <td>100.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2.4</td>\n",
       "      <td>3.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20519</th>\n",
       "      <td>1714863600000</td>\n",
       "      <td>2024-05-04 23:00:00</td>\n",
       "      <td>2024-05-04</td>\n",
       "      <td>23</td>\n",
       "      <td>9.9</td>\n",
       "      <td>100.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2.9</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           timestamp            datetime        date  hour  temperature_2m  \\\n",
       "20515  1714849200000 2024-05-04 19:00:00  2024-05-04    19            12.2   \n",
       "20516  1714852800000 2024-05-04 20:00:00  2024-05-04    20            11.4   \n",
       "20517  1714856400000 2024-05-04 21:00:00  2024-05-04    21            10.7   \n",
       "20518  1714860000000 2024-05-04 22:00:00  2024-05-04    22            10.1   \n",
       "20519  1714863600000 2024-05-04 23:00:00  2024-05-04    23             9.9   \n",
       "\n",
       "       relative_humidity_2m  precipitation  rain  snowfall  weather_code  \\\n",
       "20515                  88.0            0.0   0.0       0.0           3.0   \n",
       "20516                  92.0            0.0   0.0       0.0           2.0   \n",
       "20517                  96.0            0.0   0.0       0.0           2.0   \n",
       "20518                 100.0            0.0   0.0       0.0           3.0   \n",
       "20519                 100.0            0.0   0.0       0.0           3.0   \n",
       "\n",
       "       cloud_cover  wind_speed_10m  wind_gusts_10m  \n",
       "20515        100.0             1.6             4.3  \n",
       "20516         70.0             1.5             2.2  \n",
       "20517         64.0             0.4             2.5  \n",
       "20518        100.0             2.4             3.2  \n",
       "20519        100.0             2.9             4.0  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Display the last 5 rows of the weather dataframe\n",
    "historical_weather_df.tail(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 20520 entries, 0 to 20519\n",
      "Data columns (total 13 columns):\n",
      " #   Column                Non-Null Count  Dtype         \n",
      "---  ------                --------------  -----         \n",
      " 0   timestamp             20520 non-null  int64         \n",
      " 1   datetime              20520 non-null  datetime64[ns]\n",
      " 2   date                  20520 non-null  object        \n",
      " 3   hour                  20520 non-null  int64         \n",
      " 4   temperature_2m        20520 non-null  float64       \n",
      " 5   relative_humidity_2m  20520 non-null  float64       \n",
      " 6   precipitation         20520 non-null  float64       \n",
      " 7   rain                  20520 non-null  float64       \n",
      " 8   snowfall              20520 non-null  float64       \n",
      " 9   weather_code          20520 non-null  float64       \n",
      " 10  cloud_cover           20520 non-null  float64       \n",
      " 11  wind_speed_10m        20520 non-null  float64       \n",
      " 12  wind_gusts_10m        20520 non-null  float64       \n",
      "dtypes: datetime64[ns](1), float64(9), int64(2), object(1)\n",
      "memory usage: 2.2+ MB\n"
     ]
    }
   ],
   "source": [
    "# Show the information for the weather dataframe\n",
    "historical_weather_df.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### <span style=\"color:#2656a3;\"> 🌈  Forecast Weather Measures\n",
    "Weather Forecast from Open Meteo is now being fetched. This data is used in the `2_feature_pipeline` to parse in new real-time weather data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Fetching weather forecast measures for the next 5 days\n",
    "weather_forecast_df = weather_measures.forecast_weather_measures(\n",
    "    forecast_length=5\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>timestamp</th>\n",
       "      <th>datetime</th>\n",
       "      <th>date</th>\n",
       "      <th>hour</th>\n",
       "      <th>temperature_2m</th>\n",
       "      <th>relative_humidity_2m</th>\n",
       "      <th>precipitation</th>\n",
       "      <th>rain</th>\n",
       "      <th>snowfall</th>\n",
       "      <th>weather_code</th>\n",
       "      <th>cloud_cover</th>\n",
       "      <th>wind_speed_10m</th>\n",
       "      <th>wind_gusts_10m</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1714953600000</td>\n",
       "      <td>2024-05-06 00:00:00</td>\n",
       "      <td>2024-05-06</td>\n",
       "      <td>0</td>\n",
       "      <td>9.6</td>\n",
       "      <td>93.0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.0</td>\n",
       "      <td>51.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>14.4</td>\n",
       "      <td>24.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1714957200000</td>\n",
       "      <td>2024-05-06 01:00:00</td>\n",
       "      <td>2024-05-06</td>\n",
       "      <td>1</td>\n",
       "      <td>9.7</td>\n",
       "      <td>93.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>24.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1714960800000</td>\n",
       "      <td>2024-05-06 02:00:00</td>\n",
       "      <td>2024-05-06</td>\n",
       "      <td>2</td>\n",
       "      <td>9.5</td>\n",
       "      <td>91.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>24.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1714964400000</td>\n",
       "      <td>2024-05-06 03:00:00</td>\n",
       "      <td>2024-05-06</td>\n",
       "      <td>3</td>\n",
       "      <td>9.5</td>\n",
       "      <td>91.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>23.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1714968000000</td>\n",
       "      <td>2024-05-06 04:00:00</td>\n",
       "      <td>2024-05-06</td>\n",
       "      <td>4</td>\n",
       "      <td>9.6</td>\n",
       "      <td>92.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>100.0</td>\n",
       "      <td>14.0</td>\n",
       "      <td>24.1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       timestamp            datetime        date  hour  temperature_2m  \\\n",
       "0  1714953600000 2024-05-06 00:00:00  2024-05-06     0             9.6   \n",
       "1  1714957200000 2024-05-06 01:00:00  2024-05-06     1             9.7   \n",
       "2  1714960800000 2024-05-06 02:00:00  2024-05-06     2             9.5   \n",
       "3  1714964400000 2024-05-06 03:00:00  2024-05-06     3             9.5   \n",
       "4  1714968000000 2024-05-06 04:00:00  2024-05-06     4             9.6   \n",
       "\n",
       "   relative_humidity_2m  precipitation  rain  snowfall  weather_code  \\\n",
       "0                  93.0            0.2   0.2       0.0          51.0   \n",
       "1                  93.0            0.0   0.0       0.0           3.0   \n",
       "2                  91.0            0.0   0.0       0.0           3.0   \n",
       "3                  91.0            0.0   0.0       0.0           3.0   \n",
       "4                  92.0            0.0   0.0       0.0           3.0   \n",
       "\n",
       "   cloud_cover  wind_speed_10m  wind_gusts_10m  \n",
       "0        100.0            14.4            24.8  \n",
       "1        100.0            14.0            24.8  \n",
       "2        100.0            14.0            24.8  \n",
       "3        100.0            13.0            23.4  \n",
       "4        100.0            14.0            24.1  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Display the first 5 rows of the weather forecast dataframe\n",
    "weather_forecast_df.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>timestamp</th>\n",
       "      <th>datetime</th>\n",
       "      <th>date</th>\n",
       "      <th>hour</th>\n",
       "      <th>temperature_2m</th>\n",
       "      <th>relative_humidity_2m</th>\n",
       "      <th>precipitation</th>\n",
       "      <th>rain</th>\n",
       "      <th>snowfall</th>\n",
       "      <th>weather_code</th>\n",
       "      <th>cloud_cover</th>\n",
       "      <th>wind_speed_10m</th>\n",
       "      <th>wind_gusts_10m</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>115</th>\n",
       "      <td>1715367600000</td>\n",
       "      <td>2024-05-10 19:00:00</td>\n",
       "      <td>2024-05-10</td>\n",
       "      <td>19</td>\n",
       "      <td>11.5</td>\n",
       "      <td>68.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>89.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>13.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>116</th>\n",
       "      <td>1715371200000</td>\n",
       "      <td>2024-05-10 20:00:00</td>\n",
       "      <td>2024-05-10</td>\n",
       "      <td>20</td>\n",
       "      <td>10.5</td>\n",
       "      <td>71.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>88.0</td>\n",
       "      <td>3.4</td>\n",
       "      <td>8.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>117</th>\n",
       "      <td>1715374800000</td>\n",
       "      <td>2024-05-10 21:00:00</td>\n",
       "      <td>2024-05-10</td>\n",
       "      <td>21</td>\n",
       "      <td>9.5</td>\n",
       "      <td>74.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>87.0</td>\n",
       "      <td>2.5</td>\n",
       "      <td>4.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>118</th>\n",
       "      <td>1715378400000</td>\n",
       "      <td>2024-05-10 22:00:00</td>\n",
       "      <td>2024-05-10</td>\n",
       "      <td>22</td>\n",
       "      <td>8.6</td>\n",
       "      <td>78.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>91.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>4.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119</th>\n",
       "      <td>1715382000000</td>\n",
       "      <td>2024-05-10 23:00:00</td>\n",
       "      <td>2024-05-10</td>\n",
       "      <td>23</td>\n",
       "      <td>7.8</td>\n",
       "      <td>81.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>96.0</td>\n",
       "      <td>2.5</td>\n",
       "      <td>4.3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         timestamp            datetime        date  hour  temperature_2m  \\\n",
       "115  1715367600000 2024-05-10 19:00:00  2024-05-10    19            11.5   \n",
       "116  1715371200000 2024-05-10 20:00:00  2024-05-10    20            10.5   \n",
       "117  1715374800000 2024-05-10 21:00:00  2024-05-10    21             9.5   \n",
       "118  1715378400000 2024-05-10 22:00:00  2024-05-10    22             8.6   \n",
       "119  1715382000000 2024-05-10 23:00:00  2024-05-10    23             7.8   \n",
       "\n",
       "     relative_humidity_2m  precipitation  rain  snowfall  weather_code  \\\n",
       "115                  68.0            0.0   0.0       0.0           3.0   \n",
       "116                  71.0            0.0   0.0       0.0           3.0   \n",
       "117                  74.0            0.0   0.0       0.0           3.0   \n",
       "118                  78.0            0.0   0.0       0.0           3.0   \n",
       "119                  81.0            0.0   0.0       0.0           3.0   \n",
       "\n",
       "     cloud_cover  wind_speed_10m  wind_gusts_10m  \n",
       "115         89.0             5.2            13.0  \n",
       "116         88.0             3.4             8.6  \n",
       "117         87.0             2.5             4.3  \n",
       "118         91.0             2.6             4.3  \n",
       "119         96.0             2.5             4.3  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Display the last 5 rows of the weather forecast dataframe\n",
    "weather_forecast_df.tail(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 120 entries, 0 to 119\n",
      "Data columns (total 13 columns):\n",
      " #   Column                Non-Null Count  Dtype         \n",
      "---  ------                --------------  -----         \n",
      " 0   timestamp             120 non-null    int64         \n",
      " 1   datetime              120 non-null    datetime64[ns]\n",
      " 2   date                  120 non-null    object        \n",
      " 3   hour                  120 non-null    int64         \n",
      " 4   temperature_2m        120 non-null    float64       \n",
      " 5   relative_humidity_2m  120 non-null    float64       \n",
      " 6   precipitation         120 non-null    float64       \n",
      " 7   rain                  120 non-null    float64       \n",
      " 8   snowfall              120 non-null    float64       \n",
      " 9   weather_code          120 non-null    float64       \n",
      " 10  cloud_cover           120 non-null    float64       \n",
      " 11  wind_speed_10m        120 non-null    float64       \n",
      " 12  wind_gusts_10m        120 non-null    float64       \n",
      "dtypes: datetime64[ns](1), float64(9), int64(2), object(1)\n",
      "memory usage: 12.3+ KB\n"
     ]
    }
   ],
   "source": [
    "# Show the information for the weather weather forecast dataframe\n",
    "weather_forecast_df.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### <span style=\"color:#2656a3;\"> πŸ—“οΈ Calendar of Danish workdays and holidays \n",
    "Lastly, the calendar data is being loaded in. The calendar data includes a `workday` attribute indicating whether the date is a workday or not. This column has been encoded from categorical variables into numerical form in the folder `features/weather_measures`. `1` indicating a workday and `0` indicating a non-workday.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Fetching the Danish calendar from January 1, 2022 to December 31, 2024 \n",
    "calender_df = calendar.dk_calendar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>dayofweek</th>\n",
       "      <th>day</th>\n",
       "      <th>month</th>\n",
       "      <th>year</th>\n",
       "      <th>workday</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2022-01-01</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2022</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2022-01-02</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>2022</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2022-01-03</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2022</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2022-01-04</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>2022</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2022-01-05</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>2022</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         date  dayofweek  day  month  year  workday\n",
       "0  2022-01-01          5    1      1  2022        0\n",
       "1  2022-01-02          6    2      1  2022        0\n",
       "2  2022-01-03          0    3      1  2022        1\n",
       "3  2022-01-04          1    4      1  2022        1\n",
       "4  2022-01-05          2    5      1  2022        1"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Display the first 5 rows of the calendar dataframe\n",
    "calender_df.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>dayofweek</th>\n",
       "      <th>day</th>\n",
       "      <th>month</th>\n",
       "      <th>year</th>\n",
       "      <th>workday</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1091</th>\n",
       "      <td>2024-12-27</td>\n",
       "      <td>4</td>\n",
       "      <td>27</td>\n",
       "      <td>12</td>\n",
       "      <td>2024</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1092</th>\n",
       "      <td>2024-12-28</td>\n",
       "      <td>5</td>\n",
       "      <td>28</td>\n",
       "      <td>12</td>\n",
       "      <td>2024</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1093</th>\n",
       "      <td>2024-12-29</td>\n",
       "      <td>6</td>\n",
       "      <td>29</td>\n",
       "      <td>12</td>\n",
       "      <td>2024</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1094</th>\n",
       "      <td>2024-12-30</td>\n",
       "      <td>0</td>\n",
       "      <td>30</td>\n",
       "      <td>12</td>\n",
       "      <td>2024</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1095</th>\n",
       "      <td>2024-12-31</td>\n",
       "      <td>1</td>\n",
       "      <td>31</td>\n",
       "      <td>12</td>\n",
       "      <td>2024</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            date  dayofweek  day  month  year  workday\n",
       "1091  2024-12-27          4   27     12  2024        1\n",
       "1092  2024-12-28          5   28     12  2024        0\n",
       "1093  2024-12-29          6   29     12  2024        0\n",
       "1094  2024-12-30          0   30     12  2024        1\n",
       "1095  2024-12-31          1   31     12  2024        1"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Display the last 5 rows of the calendar dataframe\n",
    "calender_df.tail(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 1096 entries, 0 to 1095\n",
      "Data columns (total 6 columns):\n",
      " #   Column     Non-Null Count  Dtype \n",
      "---  ------     --------------  ----- \n",
      " 0   date       1096 non-null   object\n",
      " 1   dayofweek  1096 non-null   int64 \n",
      " 2   day        1096 non-null   int64 \n",
      " 3   month      1096 non-null   int64 \n",
      " 4   year       1096 non-null   int64 \n",
      " 5   workday    1096 non-null   int64 \n",
      "dtypes: int64(5), object(1)\n",
      "memory usage: 51.5+ KB\n"
     ]
    }
   ],
   "source": [
    "# Show the information for the calendar dataframe\n",
    "calender_df.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## <span style=\"color:#2656a3;\"> πŸ“‘ Connecting to Hopsworks Feature Store\n",
    "\n",
    "We connect to Hopsworks Feature Store so we can access and create feature groups."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Connected. Call `.close()` to terminate connection gracefully.\n",
      "\n",
      "Logged in to project, explore it here https://c.app.hopsworks.ai:443/p/550040\n",
      "Connected. Call `.close()` to terminate connection gracefully.\n"
     ]
    }
   ],
   "source": [
    "# Importing the hopsworks module for interacting with the Hopsworks platform\n",
    "import hopsworks\n",
    "\n",
    "# Logging into the Hopsworks project\n",
    "project = hopsworks.login()\n",
    "\n",
    "# Getting the feature store from the project\n",
    "fs = project.get_feature_store()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### <span style=\"color:#2656a3;\"> πŸͺ„ Creating Feature Groups\n",
    "A feature group can be seen as a collection of conceptually related features. In this case we create feature groups for the \n",
    "- eletricity price data,\n",
    "- weather data,\n",
    "- calendar data.\n",
    "\n",
    "We specify a `primary_key` as `date` and `timestamp`, so we are able to join them when we create a dataset for training later in part `3_training_pipeline`.\n",
    "We define a name and a short describtion of the feature group's contents and a version number. \n",
    "\n",
    "`event_time` is specifyed as `timestamp`. If event_time is set the feature group can be used for point-in-time joins.\n",
    "\n",
    "We've set `online_enabled` to `True` to enable accessing the feature group through the Online API for a Feature View."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Creating the feature group for the electricity prices\n",
    "electricity_fg = fs.get_or_create_feature_group(\n",
    "    name=\"electricity_prices\",\n",
    "    version=1,\n",
    "    description=\"Electricity prices from Energidata API\",\n",
    "    primary_key=[\"date\",\"timestamp\"], \n",
    "    online_enabled=True,\n",
    "    event_time=\"timestamp\",\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We have now outlined metadata for the feature group. Data hasn't been stored yet, and there's no schema defined. To store data persistently for the feature group, we populate it with its associated data using the `insert` function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Feature Group created successfully, explore it at \n",
      "https://c.app.hopsworks.ai:443/p/550040/fs/545863/fg/787801\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Uploading Dataframe: 100.00% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| Rows 20541/20541 | Elapsed Time: 00:08 | Remaining Time: 00:00\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Launching job: electricity_prices_1_offline_fg_materialization\n",
      "Job started successfully, you can follow the progress at \n",
      "https://c.app.hopsworks.ai/p/550040/jobs/named/electricity_prices_1_offline_fg_materialization/executions\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(<hsfs.core.job.Job at 0x12fc0d450>, None)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Inserting the electricity_df into the feature group named electricity_fg\n",
    "electricity_fg.insert(electricity_df)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We make a descriptions for each feature we put into the feature group. In this way we are adding more information and documentation to the user."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "# List of descriptions for electricity features\n",
    "electricity_feature_descriptions = [\n",
    "    {\"name\": \"timestamp\", \"description\": \"Timestamp of the event time\"},\n",
    "    {\"name\": \"date\", \"description\": \"Date of the electricity measurement\"},\n",
    "    {\"name\": \"datetime\", \"description\": \"Date and time of the electricity measurement\"},\n",
    "    {\"name\": \"hour\", \"description\": \"Hour of the day\"},\n",
    "    {\"name\": \"dk1_spotpricedkk_kwh\", \"description\": \"Spot price in DKK per KWH\"}, \n",
    "]\n",
    "\n",
    "# Updating feature descriptions\n",
    "for desc in electricity_feature_descriptions: \n",
    "    electricity_fg.update_feature_description(desc[\"name\"], desc[\"description\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We replicate the process for both the `weather_fg` and `danish_holidays_fg` by establishing feature groups and inserting the dataframes into their respective feature groups."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Creating the feature group for the weather data\n",
    "weather_fg = fs.get_or_create_feature_group(\n",
    "    name=\"weather_measurements\",\n",
    "    version=1,\n",
    "    description=\"Weather measurements from Open Meteo API\",\n",
    "    primary_key=[\"date\", \"timestamp\"], \n",
    "    online_enabled=True,\n",
    "    event_time=\"timestamp\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Feature Group created successfully, explore it at \n",
      "https://c.app.hopsworks.ai:443/p/550040/fs/545863/fg/786783\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Uploading Dataframe: 100.00% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| Rows 20520/20520 | Elapsed Time: 00:08 | Remaining Time: 00:00\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Launching job: weather_measurements_1_offline_fg_materialization\n",
      "Job started successfully, you can follow the progress at \n",
      "https://c.app.hopsworks.ai/p/550040/jobs/named/weather_measurements_1_offline_fg_materialization/executions\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(<hsfs.core.job.Job at 0x12fbb3b50>, None)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Inserting the weather_df into the feature group named weather_fg\n",
    "weather_fg.insert(historical_weather_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "# List of descriptions for weather features\n",
    "weather_feature_descriptions = [\n",
    "    {\"name\": \"timestamp\", \"description\": \"Timestamp for the weather measurement\"},\n",
    "    {\"name\": \"date\", \"description\": \"Date of the weather measurement\"},\n",
    "    {\"name\": \"datetime\", \"description\": \"Date and time of the weather measurement\"},\n",
    "    {\"name\": \"hour\", \"description\": \"Hour of the day\"},\n",
    "    {\"name\": \"temperature_2m\", \"description\": \"Temperature at 2m above ground\"},\n",
    "    {\"name\": \"relative_humidity_2m\", \"description\": \"Relative humidity at 2m above ground\"},\n",
    "    {\"name\": \"precipitation\", \"description\": \"Precipitation\"},\n",
    "    {\"name\": \"rain\", \"description\": \"Rain\"},\n",
    "    {\"name\": \"snowfall\", \"description\": \"Snowfall\"},   \n",
    "    {\"name\": \"weather_code\", \"description\": \"Weather code\"},   \n",
    "    {\"name\": \"cloud_cover\", \"description\": \"Cloud cover\"},   \n",
    "    {\"name\": \"wind_speed_10m\", \"description\": \"Wind speed at 10m above ground\"},   \n",
    "    {\"name\": \"wind_gusts_10m\", \"description\": \"Wind gusts at 10m above ground\"},   \n",
    "]\n",
    "\n",
    "# Updating feature descriptions\n",
    "for desc in weather_feature_descriptions: \n",
    "    weather_fg.update_feature_description(desc[\"name\"], desc[\"description\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Creating the feature group for the danish calendar\n",
    "danish_calendar_fg = fs.get_or_create_feature_group(\n",
    "    name=\"dk_calendar\",\n",
    "    version=1,\n",
    "    description=\"Danish calendar\",\n",
    "    primary_key=[\"date\"],\n",
    "    online_enabled=True,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Feature Group created successfully, explore it at \n",
      "https://c.app.hopsworks.ai:443/p/550040/fs/545863/fg/786784\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Uploading Dataframe: 100.00% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| Rows 1096/1096 | Elapsed Time: 00:05 | Remaining Time: 00:00\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Launching job: dk_calendar_1_offline_fg_materialization\n",
      "Job started successfully, you can follow the progress at \n",
      "https://c.app.hopsworks.ai/p/550040/jobs/named/dk_calendar_1_offline_fg_materialization/executions\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(<hsfs.core.job.Job at 0x12fe04690>, None)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Inserting the calendar_df into the feature group named danish_calendar_fg\n",
    "danish_calendar_fg.insert(calender_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "# List of descriptions for danish_calendar features\n",
    "danish_calendar_feature_descriptions = [\n",
    "    {\"name\": \"date\", \"description\": \"Date in the calendar\"},\n",
    "    {\"name\": \"day\", \"description\": \"Day number of the week. Monday is 0 and Sunday is 6\"},\n",
    "    {\"name\": \"month\", \"description\": \"Month number of the year\"},\n",
    "    {\"name\": \"workday\", \"description\": \"Workday or not a workday. Workday is 1 and not a workday is 0\"},\n",
    "]\n",
    "\n",
    "# Updating feature descriptions\n",
    "for desc in danish_calendar_feature_descriptions: \n",
    "    danish_calendar_fg.update_feature_description(desc[\"name\"], desc[\"description\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "## <span style=\"color:#2656a3;\">⏭️ **Next:** Part 02: Feature Pipeline </span>\n",
    "\n",
    "Next we will generate new data for the Feature Groups."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "bds-streamlit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}