File size: 88,550 Bytes
cd218ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "4ef3464673447a14",
   "metadata": {},
   "source": [
    "### Data Load"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "initial_id",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-18T21:42:43.965893Z",
     "start_time": "2025-01-18T21:42:43.144021Z"
    },
    "collapsed": true
   },
   "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>source</th>\n",
       "      <th>log_message</th>\n",
       "      <th>target_label</th>\n",
       "      <th>complexity</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2025-06-27 07:20:25</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-b9718cd8-f...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1/14/2025 23:07</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>Email service experiencing issues with sending</td>\n",
       "      <td>Critical Error</td>\n",
       "      <td>bert</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1/17/2025 1:29</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>Unauthorized access to data was attempted</td>\n",
       "      <td>Security Alert</td>\n",
       "      <td>bert</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2025-07-12 00:24:16</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-4895c258-b...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2025-06-02 18:25:23</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-ee8bc8ba-9...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             timestamp           source  \\\n",
       "0  2025-06-27 07:20:25        ModernCRM   \n",
       "1      1/14/2025 23:07        ModernCRM   \n",
       "2       1/17/2025 1:29  AnalyticsEngine   \n",
       "3  2025-07-12 00:24:16         ModernHR   \n",
       "4  2025-06-02 18:25:23    BillingSystem   \n",
       "\n",
       "                                         log_message    target_label  \\\n",
       "0  nova.osapi_compute.wsgi.server [req-b9718cd8-f...     HTTP Status   \n",
       "1     Email service experiencing issues with sending  Critical Error   \n",
       "2          Unauthorized access to data was attempted  Security Alert   \n",
       "3  nova.osapi_compute.wsgi.server [req-4895c258-b...     HTTP Status   \n",
       "4  nova.osapi_compute.wsgi.server [req-ee8bc8ba-9...     HTTP Status   \n",
       "\n",
       "  complexity  \n",
       "0       bert  \n",
       "1       bert  \n",
       "2       bert  \n",
       "3       bert  \n",
       "4       bert  "
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "df = pd.read_csv(\"dataset/synthetic_logs.csv\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4495a73d8e933c6e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:53.403158Z",
     "start_time": "2025-01-15T20:27:53.387783Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['ModernCRM', 'AnalyticsEngine', 'ModernHR', 'BillingSystem',\n",
       "       'ThirdPartyAPI', 'LegacyCRM'], dtype=object)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.source.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "92da3b13bac914a7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:53.466975Z",
     "start_time": "2025-01-15T20:27:53.452028Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['HTTP Status', 'Critical Error', 'Security Alert', 'Error',\n",
       "       'System Notification', 'Resource Usage', 'User Action',\n",
       "       'Workflow Error', 'Deprecation Warning'], dtype=object)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.target_label.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b350454e0d700e15",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:53.537931Z",
     "start_time": "2025-01-15T20:27:53.521598Z"
    }
   },
   "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>source</th>\n",
       "      <th>log_message</th>\n",
       "      <th>target_label</th>\n",
       "      <th>complexity</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1683</th>\n",
       "      <td>12/13/2025 5:35</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>Backup completed successfully.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2289</th>\n",
       "      <td>1/23/2025 9:59</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>System updated to version 2.3.5.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1002</th>\n",
       "      <td>3/1/2025 7:52</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>Disk cleanup completed successfully.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1343</th>\n",
       "      <td>5/13/2025 15:57</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>System updated to version 5.7.5.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2395</th>\n",
       "      <td>5/2/2025 14:29</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>Backup ended at 2025-05-06 11:23:16.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1456</th>\n",
       "      <td>11/14/2025 17:55</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>Disk cleanup completed successfully.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>643</th>\n",
       "      <td>1/12/2025 5:21</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System updated to version 1.2.9.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1321</th>\n",
       "      <td>4/25/2025 7:16</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>System updated to version 5.4.0.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>841</th>\n",
       "      <td>11/7/2025 19:23</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>File data_7222.csv uploaded successfully by us...</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2333</th>\n",
       "      <td>8/28/2025 2:09</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>Disk cleanup completed successfully.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             timestamp           source  \\\n",
       "1683   12/13/2025 5:35        ModernCRM   \n",
       "2289    1/23/2025 9:59    ThirdPartyAPI   \n",
       "1002     3/1/2025 7:52        ModernCRM   \n",
       "1343   5/13/2025 15:57        ModernCRM   \n",
       "2395    5/2/2025 14:29    ThirdPartyAPI   \n",
       "1456  11/14/2025 17:55  AnalyticsEngine   \n",
       "643     1/12/2025 5:21         ModernHR   \n",
       "1321    4/25/2025 7:16        ModernCRM   \n",
       "841    11/7/2025 19:23         ModernHR   \n",
       "2333    8/28/2025 2:09    ThirdPartyAPI   \n",
       "\n",
       "                                            log_message         target_label  \\\n",
       "1683                     Backup completed successfully.  System Notification   \n",
       "2289                   System updated to version 2.3.5.  System Notification   \n",
       "1002               Disk cleanup completed successfully.  System Notification   \n",
       "1343                   System updated to version 5.7.5.  System Notification   \n",
       "2395               Backup ended at 2025-05-06 11:23:16.  System Notification   \n",
       "1456               Disk cleanup completed successfully.  System Notification   \n",
       "643                    System updated to version 1.2.9.  System Notification   \n",
       "1321                   System updated to version 5.4.0.  System Notification   \n",
       "841   File data_7222.csv uploaded successfully by us...  System Notification   \n",
       "2333               Disk cleanup completed successfully.  System Notification   \n",
       "\n",
       "     complexity  \n",
       "1683      regex  \n",
       "2289      regex  \n",
       "1002      regex  \n",
       "1343      regex  \n",
       "2395      regex  \n",
       "1456      regex  \n",
       "643       regex  \n",
       "1321      regex  \n",
       "841       regex  \n",
       "2333      regex  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.target_label=='System Notification'].sample(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "dc5394d70050e10d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:53.626880Z",
     "start_time": "2025-01-15T20:27:53.611502Z"
    }
   },
   "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>source</th>\n",
       "      <th>log_message</th>\n",
       "      <th>target_label</th>\n",
       "      <th>complexity</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>11/19/2025 13:14</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User243.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>12/4/2025 21:20</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User471.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139</th>\n",
       "      <td>5/8/2025 16:34</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User216.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>140</th>\n",
       "      <td>9/11/2025 8:49</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User639.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>161</th>\n",
       "      <td>3/31/2025 19:40</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User819.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>163</th>\n",
       "      <td>6/6/2025 15:29</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User938.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>307</th>\n",
       "      <td>4/12/2025 0:41</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User929.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>365</th>\n",
       "      <td>10/20/2025 22:32</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User533.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>508</th>\n",
       "      <td>4/15/2025 2:04</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>System reboot initiated by user User591.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>552</th>\n",
       "      <td>9/22/2025 20:54</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User421.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>668</th>\n",
       "      <td>9/5/2025 7:14</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User297.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>693</th>\n",
       "      <td>7/6/2025 21:40</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User159.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>697</th>\n",
       "      <td>3/13/2025 7:09</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User648.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>714</th>\n",
       "      <td>9/25/2025 23:35</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>System reboot initiated by user User600.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730</th>\n",
       "      <td>5/24/2025 11:08</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User120.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>800</th>\n",
       "      <td>8/15/2025 12:14</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User901.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>837</th>\n",
       "      <td>4/9/2025 8:28</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User876.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>852</th>\n",
       "      <td>3/31/2025 5:20</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>System reboot initiated by user User811.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>865</th>\n",
       "      <td>2/25/2025 1:40</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User964.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>889</th>\n",
       "      <td>11/30/2025 13:45</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User766.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>896</th>\n",
       "      <td>7/28/2025 11:24</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User765.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>988</th>\n",
       "      <td>9/11/2025 22:23</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User427.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1106</th>\n",
       "      <td>12/28/2025 13:32</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User246.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1159</th>\n",
       "      <td>8/5/2025 6:52</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User329.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1194</th>\n",
       "      <td>7/20/2025 9:10</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User747.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1275</th>\n",
       "      <td>7/15/2025 23:37</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User829.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1299</th>\n",
       "      <td>7/15/2025 19:19</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User966.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1304</th>\n",
       "      <td>8/10/2025 6:18</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>System reboot initiated by user User758.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1524</th>\n",
       "      <td>11/30/2025 2:39</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>System reboot initiated by user User278.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1562</th>\n",
       "      <td>8/18/2025 4:17</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>System reboot initiated by user User648.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1624</th>\n",
       "      <td>12/14/2025 5:14</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User268.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1663</th>\n",
       "      <td>10/27/2025 22:04</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User315.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1776</th>\n",
       "      <td>2/21/2025 11:56</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User155.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1803</th>\n",
       "      <td>8/22/2025 6:30</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User204.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1804</th>\n",
       "      <td>8/26/2025 21:06</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User899.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1852</th>\n",
       "      <td>1/26/2025 12:34</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User223.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1865</th>\n",
       "      <td>5/11/2025 10:58</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User932.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1956</th>\n",
       "      <td>9/26/2025 19:32</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>System reboot initiated by user User264.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2003</th>\n",
       "      <td>6/23/2025 17:54</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>System reboot initiated by user User517.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014</th>\n",
       "      <td>12/25/2025 4:33</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>System reboot initiated by user User293.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2043</th>\n",
       "      <td>9/12/2025 20:20</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>System reboot initiated by user User262.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2074</th>\n",
       "      <td>9/13/2025 8:43</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>System reboot initiated by user User937.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2228</th>\n",
       "      <td>9/3/2025 11:24</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User179.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2243</th>\n",
       "      <td>1/16/2025 7:22</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User770.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2246</th>\n",
       "      <td>3/2/2025 22:56</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User488.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2253</th>\n",
       "      <td>10/7/2025 2:20</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>System reboot initiated by user User644.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2317</th>\n",
       "      <td>3/7/2025 5:44</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>System reboot initiated by user User724.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2360</th>\n",
       "      <td>5/1/2025 4:21</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>System reboot initiated by user User876.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             timestamp           source  \\\n",
       "36    11/19/2025 13:14    BillingSystem   \n",
       "92     12/4/2025 21:20    BillingSystem   \n",
       "139     5/8/2025 16:34         ModernHR   \n",
       "140     9/11/2025 8:49  AnalyticsEngine   \n",
       "161    3/31/2025 19:40    BillingSystem   \n",
       "163     6/6/2025 15:29    BillingSystem   \n",
       "307     4/12/2025 0:41    BillingSystem   \n",
       "365   10/20/2025 22:32         ModernHR   \n",
       "508     4/15/2025 2:04    ThirdPartyAPI   \n",
       "552    9/22/2025 20:54         ModernHR   \n",
       "668      9/5/2025 7:14         ModernHR   \n",
       "693     7/6/2025 21:40    BillingSystem   \n",
       "697     3/13/2025 7:09    BillingSystem   \n",
       "714    9/25/2025 23:35    ThirdPartyAPI   \n",
       "730    5/24/2025 11:08  AnalyticsEngine   \n",
       "800    8/15/2025 12:14    BillingSystem   \n",
       "837      4/9/2025 8:28  AnalyticsEngine   \n",
       "852     3/31/2025 5:20        ModernCRM   \n",
       "865     2/25/2025 1:40  AnalyticsEngine   \n",
       "889   11/30/2025 13:45         ModernHR   \n",
       "896    7/28/2025 11:24    BillingSystem   \n",
       "988    9/11/2025 22:23    BillingSystem   \n",
       "1106  12/28/2025 13:32         ModernHR   \n",
       "1159     8/5/2025 6:52    BillingSystem   \n",
       "1194    7/20/2025 9:10  AnalyticsEngine   \n",
       "1275   7/15/2025 23:37    BillingSystem   \n",
       "1299   7/15/2025 19:19    BillingSystem   \n",
       "1304    8/10/2025 6:18    ThirdPartyAPI   \n",
       "1524   11/30/2025 2:39    ThirdPartyAPI   \n",
       "1562    8/18/2025 4:17    ThirdPartyAPI   \n",
       "1624   12/14/2025 5:14  AnalyticsEngine   \n",
       "1663  10/27/2025 22:04  AnalyticsEngine   \n",
       "1776   2/21/2025 11:56         ModernHR   \n",
       "1803    8/22/2025 6:30  AnalyticsEngine   \n",
       "1804   8/26/2025 21:06         ModernHR   \n",
       "1852   1/26/2025 12:34  AnalyticsEngine   \n",
       "1865   5/11/2025 10:58  AnalyticsEngine   \n",
       "1956   9/26/2025 19:32    ThirdPartyAPI   \n",
       "2003   6/23/2025 17:54        ModernCRM   \n",
       "2014   12/25/2025 4:33  AnalyticsEngine   \n",
       "2043   9/12/2025 20:20    ThirdPartyAPI   \n",
       "2074    9/13/2025 8:43        ModernCRM   \n",
       "2228    9/3/2025 11:24         ModernHR   \n",
       "2243    1/16/2025 7:22         ModernHR   \n",
       "2246    3/2/2025 22:56         ModernHR   \n",
       "2253    10/7/2025 2:20         ModernHR   \n",
       "2317     3/7/2025 5:44    BillingSystem   \n",
       "2360     5/1/2025 4:21    ThirdPartyAPI   \n",
       "\n",
       "                                   log_message         target_label complexity  \n",
       "36    System reboot initiated by user User243.  System Notification      regex  \n",
       "92    System reboot initiated by user User471.  System Notification      regex  \n",
       "139   System reboot initiated by user User216.  System Notification      regex  \n",
       "140   System reboot initiated by user User639.  System Notification      regex  \n",
       "161   System reboot initiated by user User819.  System Notification      regex  \n",
       "163   System reboot initiated by user User938.  System Notification      regex  \n",
       "307   System reboot initiated by user User929.  System Notification      regex  \n",
       "365   System reboot initiated by user User533.  System Notification      regex  \n",
       "508   System reboot initiated by user User591.  System Notification      regex  \n",
       "552   System reboot initiated by user User421.  System Notification      regex  \n",
       "668   System reboot initiated by user User297.  System Notification      regex  \n",
       "693   System reboot initiated by user User159.  System Notification      regex  \n",
       "697   System reboot initiated by user User648.  System Notification      regex  \n",
       "714   System reboot initiated by user User600.  System Notification      regex  \n",
       "730   System reboot initiated by user User120.  System Notification      regex  \n",
       "800   System reboot initiated by user User901.  System Notification      regex  \n",
       "837   System reboot initiated by user User876.  System Notification      regex  \n",
       "852   System reboot initiated by user User811.  System Notification      regex  \n",
       "865   System reboot initiated by user User964.  System Notification      regex  \n",
       "889   System reboot initiated by user User766.  System Notification      regex  \n",
       "896   System reboot initiated by user User765.  System Notification      regex  \n",
       "988   System reboot initiated by user User427.  System Notification      regex  \n",
       "1106  System reboot initiated by user User246.  System Notification      regex  \n",
       "1159  System reboot initiated by user User329.  System Notification      regex  \n",
       "1194  System reboot initiated by user User747.  System Notification      regex  \n",
       "1275  System reboot initiated by user User829.  System Notification      regex  \n",
       "1299  System reboot initiated by user User966.  System Notification      regex  \n",
       "1304  System reboot initiated by user User758.  System Notification      regex  \n",
       "1524  System reboot initiated by user User278.  System Notification      regex  \n",
       "1562  System reboot initiated by user User648.  System Notification      regex  \n",
       "1624  System reboot initiated by user User268.  System Notification      regex  \n",
       "1663  System reboot initiated by user User315.  System Notification      regex  \n",
       "1776  System reboot initiated by user User155.  System Notification      regex  \n",
       "1803  System reboot initiated by user User204.  System Notification      regex  \n",
       "1804  System reboot initiated by user User899.  System Notification      regex  \n",
       "1852  System reboot initiated by user User223.  System Notification      regex  \n",
       "1865  System reboot initiated by user User932.  System Notification      regex  \n",
       "1956  System reboot initiated by user User264.  System Notification      regex  \n",
       "2003  System reboot initiated by user User517.  System Notification      regex  \n",
       "2014  System reboot initiated by user User293.  System Notification      regex  \n",
       "2043  System reboot initiated by user User262.  System Notification      regex  \n",
       "2074  System reboot initiated by user User937.  System Notification      regex  \n",
       "2228  System reboot initiated by user User179.  System Notification      regex  \n",
       "2243  System reboot initiated by user User770.  System Notification      regex  \n",
       "2246  System reboot initiated by user User488.  System Notification      regex  \n",
       "2253  System reboot initiated by user User644.  System Notification      regex  \n",
       "2317  System reboot initiated by user User724.  System Notification      regex  \n",
       "2360  System reboot initiated by user User876.  System Notification      regex  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.log_message.str.startswith(\"System reboot initiated by user\")]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f9848e705b7eaa60",
   "metadata": {},
   "source": [
    "### Clustering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4ac33c95fa16ebc0",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:53.727373Z",
     "start_time": "2025-01-15T20:27:53.711739Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/yuvaraj/Desktop/projects/project-nlp-log-classification/venv/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    }
   ],
   "source": [
    "from sklearn.cluster import DBSCAN\n",
    "from sentence_transformers import SentenceTransformer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "6722e5924d2a1fc0",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:57.371284Z",
     "start_time": "2025-01-15T20:27:53.820041Z"
    }
   },
   "outputs": [],
   "source": [
    "model = SentenceTransformer('all-MiniLM-L6-v2')  # Lightweight embedding model\n",
    "embeddings = model.encode(df['log_message'].tolist())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8e97b58b60296c93",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:57.391292Z",
     "start_time": "2025-01-15T20:27:57.371284Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.10293969,  0.03354594, -0.02202599, ...,  0.00457783,\n",
       "        -0.04259719,  0.00322625],\n",
       "       [ 0.00804575, -0.03573925,  0.0493874 , ...,  0.01538318,\n",
       "        -0.0623095 , -0.02774667],\n",
       "       [-0.00908216,  0.13003923, -0.05275571, ...,  0.02014102,\n",
       "        -0.05117101, -0.02930292],\n",
       "       [-0.0975106 ,  0.04911299, -0.03977427, ...,  0.02477493,\n",
       "        -0.03546083, -0.00018602],\n",
       "       [-0.10468345,  0.05926038, -0.02488496, ...,  0.0250205 ,\n",
       "        -0.03719296, -0.02568912]], shape=(5, 384), dtype=float32)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "embeddings[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "797b761439f42836",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:57.492015Z",
     "start_time": "2025-01-15T20:27:57.421383Z"
    }
   },
   "outputs": [],
   "source": [
    "clustering = DBSCAN(eps=0.2, min_samples=1, metric='cosine').fit(embeddings)\n",
    "df['cluster'] = clustering.labels_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "f86db1d238061a83",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:57.554699Z",
     "start_time": "2025-01-15T20:27:57.540698Z"
    }
   },
   "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>source</th>\n",
       "      <th>log_message</th>\n",
       "      <th>target_label</th>\n",
       "      <th>complexity</th>\n",
       "      <th>cluster</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2025-06-27 07:20:25</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-b9718cd8-f...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1/14/2025 23:07</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>Email service experiencing issues with sending</td>\n",
       "      <td>Critical Error</td>\n",
       "      <td>bert</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1/17/2025 1:29</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>Unauthorized access to data was attempted</td>\n",
       "      <td>Security Alert</td>\n",
       "      <td>bert</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2025-07-12 00:24:16</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-4895c258-b...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2025-06-02 18:25:23</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-ee8bc8ba-9...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             timestamp           source  \\\n",
       "0  2025-06-27 07:20:25        ModernCRM   \n",
       "1      1/14/2025 23:07        ModernCRM   \n",
       "2       1/17/2025 1:29  AnalyticsEngine   \n",
       "3  2025-07-12 00:24:16         ModernHR   \n",
       "4  2025-06-02 18:25:23    BillingSystem   \n",
       "\n",
       "                                         log_message    target_label  \\\n",
       "0  nova.osapi_compute.wsgi.server [req-b9718cd8-f...     HTTP Status   \n",
       "1     Email service experiencing issues with sending  Critical Error   \n",
       "2          Unauthorized access to data was attempted  Security Alert   \n",
       "3  nova.osapi_compute.wsgi.server [req-4895c258-b...     HTTP Status   \n",
       "4  nova.osapi_compute.wsgi.server [req-ee8bc8ba-9...     HTTP Status   \n",
       "\n",
       "  complexity  cluster  \n",
       "0       bert        0  \n",
       "1       bert        1  \n",
       "2       bert        2  \n",
       "3       bert        0  \n",
       "4       bert        0  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "d3ec326ef8793ed8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:57.689518Z",
     "start_time": "2025-01-15T20:27:57.676503Z"
    }
   },
   "outputs": [],
   "source": [
    "# Group by cluster to inspect patterns\n",
    "clusters = df.groupby('cluster')['log_message'].apply(list)\n",
    "sorted_clusters = clusters.sort_values(key=lambda x: x.map(len), ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "53dd43fd2cab0141",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:58.467824Z",
     "start_time": "2025-01-15T20:27:58.449975Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Clustered Patterns:\n",
      "Cluster 0:\n",
      "  nova.osapi_compute.wsgi.server [req-b9718cd8-f65e-49cc-8349-6cf7122af137 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] 10.11.10.1 \"GET /v2/54fadb412c4e40cdbaed9335e4c35a9e/servers/detail HTTP/1.1\" status: 200 len: 1893 time: 0.2675118\n",
      "  nova.osapi_compute.wsgi.server [req-4895c258-b2f8-488f-a2a3-4fae63982e48 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] 10.11.10.1 \"GET /v2/54fadb412c4e40cdbaed9335e4c35a9e/servers/detail HTTP/1.1\" HTTP status code -  200 len: 211 time: 0.0968180\n",
      "  nova.osapi_compute.wsgi.server [req-ee8bc8ba-9265-4280-9215-dbe000a41209 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] 10.11.10.1 \"GET /v2/54fadb412c4e40cdbaed9335e4c35a9e/servers/detail HTTP/1.1\" RCODE  200 len: 1874 time: 0.2280791\n",
      "  nova.osapi_compute.wsgi.server [req-f0bffbc3-5ab0-4916-91c1-0a61dd7d4ec2 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] 10.11.10.1 \"GET /v2/54fadb412c4e40cdbaed9335e4c35a9e/servers/detail HTTP/1.1\" Return code: 200 len: 1874 time: 0.2131531\n",
      "  nova.osapi_compute.wsgi.server [req-2bf7cfee-a236-42f3-8fb1-96fefab0b302 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] 10.11.10.1 \"GET /v2/54fadb412c4e40cdbaed9335e4c35a9e/servers/detail HTTP/1.1\" RCODE  200 len: 1874 time: 0.1794369\n",
      "Cluster 5:\n",
      "  nova.compute.claims [req-a07ac654-8e81-416d-bfbb-189116b07969 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] [instance: bf8c824d-f099-4433-a41e-e3da7578262e] Total memory: 64172 MB, used: 512.00 MB\n",
      "  nova.compute.claims [req-d6986b54-3735-4a42-9074-0ba7d9717de9 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] [instance: af5f7392-f7d4-4298-b647-c98924c64aa1] memory limit: 96258.00 MB, free: 95746.00 MB\n",
      "  nova.compute.claims [req-72b4858f-049e-49e1-b31e-b562c5018eaf 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] [instance: 63a0d960-70b6-44c6-b606-491478a5cadf] disk limit not specified, defaulting to unlimited\n",
      "  nova.compute.claims [req-5c8f52bd-8e3c-41f0-95a5-7861d247cafa 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] [instance: d96a117b-0193-4549-bdcc-63b917273d1d] vcpu limit not specified, defaulting to unlimited\n",
      "  nova.compute.claims [req-d38f479d-9bb9-4276-9688-52607e8fd350 113d3a99c3da401fbd62cc2caa5b96d2 54fadb412c4e40cdbaed9335e4c35a9e - - -] [instance: 95960536-049b-41f6-9049-05fc479b6a7c] disk limit not specified, defaulting to unlimited\n",
      "Cluster 11:\n",
      "  User User685 logged out.\n",
      "  User User395 logged in.\n",
      "  User User225 logged in.\n",
      "  User User494 logged out.\n",
      "  User User900 logged in.\n",
      "Cluster 13:\n",
      "  Backup started at 2025-05-14 07:06:55.\n",
      "  Backup started at 2025-02-15 20:00:19.\n",
      "  Backup ended at 2025-08-08 13:06:23.\n",
      "  Backup started at 2025-11-14 08:27:43.\n",
      "  Backup started at 2025-12-09 10:19:11.\n",
      "Cluster 7:\n",
      "  Multiple bad login attempts detected on user 8538 account\n",
      "  Multiple login failures occurred on user 9052 account\n",
      "  User 7153 made multiple incorrect login attempts\n",
      "  User 8300 made multiple incorrect login attempts\n",
      "  Multiple login failures were detected for user 6373\n",
      "Cluster 8:\n",
      "  Backup completed successfully.\n",
      "  Backup completed successfully.\n",
      "  Backup completed successfully.\n",
      "  Backup completed successfully.\n",
      "  Backup completed successfully.\n",
      "Cluster 21:\n",
      "  System updated to version 3.9.1.\n",
      "  System updated to version 5.5.4.\n",
      "  System updated to version 4.7.4.\n",
      "  System updated to version 3.7.7.\n",
      "  System updated to version 2.6.2.\n",
      "Cluster 3:\n",
      "  Shard 6 replication task ended in failure\n",
      "  Data replication task for shard 14 did not complete\n",
      "  Data replication task failed for shard 17\n",
      "  Replication of data to shard 14 failed\n",
      "  Data replication task for shard 6 did not complete\n",
      "Cluster 4:\n",
      "  File data_6169.csv uploaded successfully by user User953.\n",
      "  File data_3847.csv uploaded successfully by user User175.\n",
      "  File data_7366.csv uploaded successfully by user User282.\n",
      "  File data_1206.csv uploaded successfully by user User359.\n",
      "  File data_1503.csv uploaded successfully by user User151.\n",
      "Cluster 17:\n",
      "  Denied access attempt on restricted account Account2682\n",
      "  Unauthorized login attempt on protected account Account5030\n",
      "  Account Account9437 blocked due to failed login\n",
      "  Account Account7999 access denied due to login failure\n",
      "  Invalid login attempt made on secured account Account7864\n",
      "Cluster 32:\n",
      "  Disk cleanup completed successfully.\n",
      "  Disk cleanup completed successfully.\n",
      "  Disk cleanup completed successfully.\n",
      "  Disk cleanup completed successfully.\n",
      "  Disk cleanup completed successfully.\n",
      "Cluster 6:\n",
      "  Critical system unit error: unit ID Component55\n",
      "  System component malfunction: component ID Component79\n",
      "  Critical system element is down: element ID Component96\n",
      "  Essential system part malfunction: part ID Component6\n",
      "  Failure occurred in critical system component: component ID Component92\n",
      "Cluster 16:\n",
      "  System reboot initiated by user User243.\n",
      "  System reboot initiated by user User471.\n",
      "  System reboot initiated by user User216.\n",
      "  System reboot initiated by user User639.\n",
      "  System reboot initiated by user User819.\n",
      "Cluster 20:\n",
      "  User 7662 tried to bypass API security measures\n",
      "  User 2367 failed to provide valid API access credentials\n",
      "  User 3569 made an unauthorized API request\n",
      "  Unauthorized user 2968 tried to access restricted API\n",
      "  User 2186 attempted to access API without proper authorization\n",
      "Cluster 9:\n",
      "  Account with ID 5351 created by User634.\n",
      "  Account with ID 7813 created by User373.\n",
      "  Account with ID 9827 created by User965.\n",
      "  Account with ID 2520 created by User546.\n",
      "  Account with ID 2300 created by User964.\n",
      "Cluster 1:\n",
      "  Email service experiencing issues with sending\n",
      "  Email server encountered a sending fault\n",
      "  Mail service encountered a delivery glitch\n",
      "  Service disruption caused by email sending error\n",
      "  Email system had a problem sending emails\n",
      "Cluster 10:\n",
      "  nova.compute.resource_tracker [req-addc1839-2ed5-4778-b57e-5854eb7b8b09 - - - - -] Final resource view: name=cp-1.slowvm1.tcloud-pg0.utah.cloudlab.us phys_ram=64172MB used_ram=512MB phys_disk=15GB used_disk=0GB total_vcpus=16 used_vcpus=0 pci_stats=[]\n",
      "  nova.compute.resource_tracker [req-addc1839-2ed5-4778-b57e-5854eb7b8b09 - - - - -] Final resource view: name=cp-1.slowvm1.tcloud-pg0.utah.cloudlab.us phys_ram=64172MB used_ram=2560MB phys_disk=15GB used_disk=20GB total_vcpus=16 used_vcpus=1 pci_stats=[]\n",
      "  nova.compute.resource_tracker [req-addc1839-2ed5-4778-b57e-5854eb7b8b09 - - - - -] Total usable vcpus: 16, total allocated vcpus: 0\n",
      "  nova.compute.resource_tracker [req-addc1839-2ed5-4778-b57e-5854eb7b8b09 - - - - -] Final resource view: name=cp-1.slowvm1.tcloud-pg0.utah.cloudlab.us phys_ram=64172MB used_ram=2560MB phys_disk=15GB used_disk=20GB total_vcpus=16 used_vcpus=1 pci_stats=[]\n",
      "  nova.compute.resource_tracker [req-addc1839-2ed5-4778-b57e-5854eb7b8b09 - - - - -] Final resource view: name=cp-1.slowvm1.tcloud-pg0.utah.cloudlab.us phys_ram=64172MB used_ram=2560MB phys_disk=15GB used_disk=20GB total_vcpus=16 used_vcpus=1 pci_stats=[]\n",
      "Cluster 34:\n",
      "  Abnormal behavior found on server 10, possible security threat\n",
      "  Security alert: suspicious activity on server 1\n",
      "  Anomalous activity identified on server 23, security review recommended\n",
      "  Server 27 experienced potential security incident, review required\n",
      "  Server 36 experienced potential security incident, review required\n",
      "Cluster 14:\n",
      "  Detection of multiple disk faults in RAID setup\n",
      "  RAID array suffered multiple hard drive failures\n",
      "  RAID array experienced multiple disk crashes\n",
      "  Multiple hard drive issues in RAID configuration found\n",
      "  Identification of multiple faulty disks in RAID array\n",
      "Cluster 53:\n",
      "  Module X experienced an invalid data format issue\n",
      "  Input format mismatch occurred in module X\n",
      "  Module X reported an error in input format validation\n",
      "  Module X failed to process input due to formatting error\n",
      "  Input data format in module X was invalid or corrupted\n",
      "Cluster 52:\n",
      "  Service health check was not successful because of SSL certificate validation failures.\n",
      "  Invalid SSL certificate resulted in a failed service health check.\n",
      "  Service health check failure was due to an invalid or improperly configured SSL certificate.\n",
      "  An issue with the SSL certificate caused the service health check to fail.\n",
      "  Service health check failure was caused by an expired SSL certificate.\n",
      "Cluster 18:\n",
      "  Boot process terminated unexpectedly due to kernel issue\n",
      "  System encountered kernel panic during initialization phase\n",
      "  Boot process was stopped by kernel malfunction\n",
      "  System encountered kernel failure during bootup sequence\n",
      "  Boot sequence failed due to kernel panic\n",
      "Cluster 25:\n",
      "  System configuration is no longer valid\n",
      "  Configuration is corrupted throughout the system\n",
      "  Cross-system configuration failure occurred\n",
      "  System configuration is experiencing errors\n",
      "  Configuration malfunction is system-wide\n",
      "Cluster 42:\n",
      "  User 5127 has escalated admin privileges without authorization\n",
      "  User 9745 has escalated to admin level\n",
      "  User 8483 escalated privileges to admin level\n",
      "  User 1987 has escalated to admin level\n",
      "  User 8395 escalated privileges to admin level\n",
      "Cluster 59:\n",
      "  Potential security threat: Admin privilege escalation for user 5130\n",
      "  Admin privilege escalation alert for user 2893\n",
      "  Admin privilege escalation alert for user 8532\n",
      "  Potential security threat: Admin privilege escalation for user 1554\n",
      "  Warning: Potential admin privilege escalation for user 5720\n",
      "Cluster 26:\n",
      "  Privilege elevation detected for user 5038\n",
      "  Elevation of admin privileges detected for user 6137\n",
      "  Elevation of admin privileges detected for user 4907\n",
      "  User 6069 has been granted elevated admin privileges\n",
      "  Admin privilege elevation warning for user 7574\n"
     ]
    }
   ],
   "source": [
    "print(\"Clustered Patterns:\")\n",
    "for cluster_id, messages in sorted_clusters.items():\n",
    "    if len(messages) > 10:\n",
    "        print(f\"Cluster {cluster_id}:\")\n",
    "        for msg in messages[:5]:\n",
    "            print(f\"  {msg}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bbec6795396f2d6b",
   "metadata": {},
   "source": [
    "### Classification Stage 1: Regex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "ca32020e4fdb8f40",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:58.549493Z",
     "start_time": "2025-01-15T20:27:58.529458Z"
    }
   },
   "outputs": [],
   "source": [
    "import re\n",
    "def classify_with_regex(log_message):\n",
    "    regex_patterns = {\n",
    "        r\"User User\\d+ logged (in|out).\": \"User Action\",\n",
    "        r\"Backup (started|ended) at .*\": \"System Notification\",\n",
    "        r\"Backup completed successfully.\": \"System Notification\",\n",
    "        r\"System updated to version .*\": \"System Notification\",\n",
    "        r\"File .* uploaded successfully by user .*\": \"System Notification\",\n",
    "        r\"Disk cleanup completed successfully.\": \"System Notification\",\n",
    "        r\"System reboot initiated by user .*\": \"System Notification\",\n",
    "        r\"Account with ID .* created by .*\": \"User Action\"\n",
    "    }\n",
    "    for pattern, label in regex_patterns.items():\n",
    "        if re.search(pattern, log_message):\n",
    "            return label\n",
    "    return None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "4d9645ec6812da4a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:58.589510Z",
     "start_time": "2025-01-15T20:27:58.579485Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'User Action'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "classify_with_regex(\"User User123 logged in.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6b3b838a2d270190",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:58.636755Z",
     "start_time": "2025-01-15T20:27:58.624648Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'System Notification'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "classify_with_regex(\"System reboot initiated by user User179.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "99bcfd70b451835c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:58.682792Z",
     "start_time": "2025-01-15T20:27:58.672822Z"
    }
   },
   "outputs": [],
   "source": [
    "classify_with_regex(\"Hey you, chill bro\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "22619eedaa15acc3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:58.760034Z",
     "start_time": "2025-01-15T20:27:58.731326Z"
    }
   },
   "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>source</th>\n",
       "      <th>log_message</th>\n",
       "      <th>target_label</th>\n",
       "      <th>complexity</th>\n",
       "      <th>cluster</th>\n",
       "      <th>regex_label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>10/11/2025 8:44</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>File data_6169.csv uploaded successfully by us...</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "      <td>4</td>\n",
       "      <td>System Notification</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1/4/2025 1:43</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>File data_3847.csv uploaded successfully by us...</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "      <td>4</td>\n",
       "      <td>System Notification</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>5/1/2025 9:41</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>Backup completed successfully.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "      <td>8</td>\n",
       "      <td>System Notification</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2/22/2025 17:49</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>Account with ID 5351 created by User634.</td>\n",
       "      <td>User Action</td>\n",
       "      <td>regex</td>\n",
       "      <td>9</td>\n",
       "      <td>User Action</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>9/24/2025 19:57</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>User User685 logged out.</td>\n",
       "      <td>User Action</td>\n",
       "      <td>regex</td>\n",
       "      <td>11</td>\n",
       "      <td>User Action</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2376</th>\n",
       "      <td>6/27/2025 8:47</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>System updated to version 2.0.5.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "      <td>21</td>\n",
       "      <td>System Notification</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2381</th>\n",
       "      <td>9/5/2025 6:39</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>Disk cleanup completed successfully.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "      <td>32</td>\n",
       "      <td>System Notification</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2394</th>\n",
       "      <td>4/3/2025 13:13</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>Disk cleanup completed successfully.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "      <td>32</td>\n",
       "      <td>System Notification</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2395</th>\n",
       "      <td>5/2/2025 14:29</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>Backup ended at 2025-05-06 11:23:16.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "      <td>13</td>\n",
       "      <td>System Notification</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2403</th>\n",
       "      <td>10/1/2025 1:31</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>Backup completed successfully.</td>\n",
       "      <td>System Notification</td>\n",
       "      <td>regex</td>\n",
       "      <td>8</td>\n",
       "      <td>System Notification</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            timestamp         source  \\\n",
       "7     10/11/2025 8:44       ModernHR   \n",
       "14      1/4/2025 1:43  ThirdPartyAPI   \n",
       "15      5/1/2025 9:41      ModernCRM   \n",
       "18    2/22/2025 17:49      ModernCRM   \n",
       "27    9/24/2025 19:57  ThirdPartyAPI   \n",
       "...               ...            ...   \n",
       "2376   6/27/2025 8:47      ModernCRM   \n",
       "2381    9/5/2025 6:39  ThirdPartyAPI   \n",
       "2394   4/3/2025 13:13       ModernHR   \n",
       "2395   5/2/2025 14:29  ThirdPartyAPI   \n",
       "2403   10/1/2025 1:31      ModernCRM   \n",
       "\n",
       "                                            log_message         target_label  \\\n",
       "7     File data_6169.csv uploaded successfully by us...  System Notification   \n",
       "14    File data_3847.csv uploaded successfully by us...  System Notification   \n",
       "15                       Backup completed successfully.  System Notification   \n",
       "18             Account with ID 5351 created by User634.          User Action   \n",
       "27                             User User685 logged out.          User Action   \n",
       "...                                                 ...                  ...   \n",
       "2376                   System updated to version 2.0.5.  System Notification   \n",
       "2381               Disk cleanup completed successfully.  System Notification   \n",
       "2394               Disk cleanup completed successfully.  System Notification   \n",
       "2395               Backup ended at 2025-05-06 11:23:16.  System Notification   \n",
       "2403                     Backup completed successfully.  System Notification   \n",
       "\n",
       "     complexity  cluster          regex_label  \n",
       "7         regex        4  System Notification  \n",
       "14        regex        4  System Notification  \n",
       "15        regex        8  System Notification  \n",
       "18        regex        9          User Action  \n",
       "27        regex       11          User Action  \n",
       "...         ...      ...                  ...  \n",
       "2376      regex       21  System Notification  \n",
       "2381      regex       32  System Notification  \n",
       "2394      regex       32  System Notification  \n",
       "2395      regex       13  System Notification  \n",
       "2403      regex        8  System Notification  \n",
       "\n",
       "[500 rows x 7 columns]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Apply regex classification\n",
    "df['regex_label'] = df['log_message'].apply(lambda x: classify_with_regex(x))\n",
    "df[df['regex_label'].notnull()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e12979fc8238277f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:27:58.806198Z",
     "start_time": "2025-01-15T20:27:58.792662Z"
    }
   },
   "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>source</th>\n",
       "      <th>log_message</th>\n",
       "      <th>target_label</th>\n",
       "      <th>complexity</th>\n",
       "      <th>cluster</th>\n",
       "      <th>regex_label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2025-06-27 07:20:25</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-b9718cd8-f...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1/14/2025 23:07</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>Email service experiencing issues with sending</td>\n",
       "      <td>Critical Error</td>\n",
       "      <td>bert</td>\n",
       "      <td>1</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1/17/2025 1:29</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>Unauthorized access to data was attempted</td>\n",
       "      <td>Security Alert</td>\n",
       "      <td>bert</td>\n",
       "      <td>2</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2025-07-12 00:24:16</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-4895c258-b...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2025-06-02 18:25:23</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-ee8bc8ba-9...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             timestamp           source  \\\n",
       "0  2025-06-27 07:20:25        ModernCRM   \n",
       "1      1/14/2025 23:07        ModernCRM   \n",
       "2       1/17/2025 1:29  AnalyticsEngine   \n",
       "3  2025-07-12 00:24:16         ModernHR   \n",
       "4  2025-06-02 18:25:23    BillingSystem   \n",
       "\n",
       "                                         log_message    target_label  \\\n",
       "0  nova.osapi_compute.wsgi.server [req-b9718cd8-f...     HTTP Status   \n",
       "1     Email service experiencing issues with sending  Critical Error   \n",
       "2          Unauthorized access to data was attempted  Security Alert   \n",
       "3  nova.osapi_compute.wsgi.server [req-4895c258-b...     HTTP Status   \n",
       "4  nova.osapi_compute.wsgi.server [req-ee8bc8ba-9...     HTTP Status   \n",
       "\n",
       "  complexity  cluster regex_label  \n",
       "0       bert        0        None  \n",
       "1       bert        1        None  \n",
       "2       bert        2        None  \n",
       "3       bert        0        None  \n",
       "4       bert        0        None  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df['regex_label'].isnull()].head(5)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b58274a035c82628",
   "metadata": {},
   "source": [
    "### Classification Stage 2: Classification Using Embeddings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "7c21958116c1429b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:29:48.629503Z",
     "start_time": "2025-01-15T20:29:48.598340Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1910, 7)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_non_regex = df[df['regex_label'].isnull()].copy()\n",
    "df_non_regex.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "b340b51441a741a8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:30:04.093929Z",
     "start_time": "2025-01-15T20:30:04.062728Z"
    }
   },
   "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>source</th>\n",
       "      <th>log_message</th>\n",
       "      <th>target_label</th>\n",
       "      <th>complexity</th>\n",
       "      <th>cluster</th>\n",
       "      <th>regex_label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>2025-10-06 16:55:23</td>\n",
       "      <td>LegacyCRM</td>\n",
       "      <td>Lead conversion failed for prospect ID 7842 du...</td>\n",
       "      <td>Workflow Error</td>\n",
       "      <td>llm</td>\n",
       "      <td>24</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255</th>\n",
       "      <td>2025-05-03 16:55:35</td>\n",
       "      <td>LegacyCRM</td>\n",
       "      <td>API endpoint 'getCustomerDetails' is deprecate...</td>\n",
       "      <td>Deprecation Warning</td>\n",
       "      <td>llm</td>\n",
       "      <td>48</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>377</th>\n",
       "      <td>2025-06-24 12:16:29</td>\n",
       "      <td>LegacyCRM</td>\n",
       "      <td>Customer follow-up process for lead ID 5621 fa...</td>\n",
       "      <td>Workflow Error</td>\n",
       "      <td>llm</td>\n",
       "      <td>62</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1325</th>\n",
       "      <td>2025-04-17 07:33:44</td>\n",
       "      <td>LegacyCRM</td>\n",
       "      <td>Escalation rule execution failed for ticket ID...</td>\n",
       "      <td>Workflow Error</td>\n",
       "      <td>llm</td>\n",
       "      <td>105</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1734</th>\n",
       "      <td>2025-04-30 07:47:30</td>\n",
       "      <td>LegacyCRM</td>\n",
       "      <td>The 'ExportToCSV' feature is outdated. Please ...</td>\n",
       "      <td>Deprecation Warning</td>\n",
       "      <td>llm</td>\n",
       "      <td>118</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1826</th>\n",
       "      <td>2025-01-23 10:33:36</td>\n",
       "      <td>LegacyCRM</td>\n",
       "      <td>Support for legacy authentication methods will...</td>\n",
       "      <td>Deprecation Warning</td>\n",
       "      <td>llm</td>\n",
       "      <td>122</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2217</th>\n",
       "      <td>2025-05-12 09:46:54</td>\n",
       "      <td>LegacyCRM</td>\n",
       "      <td>Task assignment for TeamID 3425 could not comp...</td>\n",
       "      <td>Workflow Error</td>\n",
       "      <td>llm</td>\n",
       "      <td>133</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                timestamp     source  \\\n",
       "60    2025-10-06 16:55:23  LegacyCRM   \n",
       "255   2025-05-03 16:55:35  LegacyCRM   \n",
       "377   2025-06-24 12:16:29  LegacyCRM   \n",
       "1325  2025-04-17 07:33:44  LegacyCRM   \n",
       "1734  2025-04-30 07:47:30  LegacyCRM   \n",
       "1826  2025-01-23 10:33:36  LegacyCRM   \n",
       "2217  2025-05-12 09:46:54  LegacyCRM   \n",
       "\n",
       "                                            log_message         target_label  \\\n",
       "60    Lead conversion failed for prospect ID 7842 du...       Workflow Error   \n",
       "255   API endpoint 'getCustomerDetails' is deprecate...  Deprecation Warning   \n",
       "377   Customer follow-up process for lead ID 5621 fa...       Workflow Error   \n",
       "1325  Escalation rule execution failed for ticket ID...       Workflow Error   \n",
       "1734  The 'ExportToCSV' feature is outdated. Please ...  Deprecation Warning   \n",
       "1826  Support for legacy authentication methods will...  Deprecation Warning   \n",
       "2217  Task assignment for TeamID 3425 could not comp...       Workflow Error   \n",
       "\n",
       "     complexity  cluster regex_label  \n",
       "60          llm       24        None  \n",
       "255         llm       48        None  \n",
       "377         llm       62        None  \n",
       "1325        llm      105        None  \n",
       "1734        llm      118        None  \n",
       "1826        llm      122        None  \n",
       "2217        llm      133        None  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_legacy = df_non_regex[df_non_regex.source==\"LegacyCRM\"]\n",
    "df_legacy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "8d8f7e5902aca5f8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:30:48.679137Z",
     "start_time": "2025-01-15T20:30:48.647857Z"
    }
   },
   "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>source</th>\n",
       "      <th>log_message</th>\n",
       "      <th>target_label</th>\n",
       "      <th>complexity</th>\n",
       "      <th>cluster</th>\n",
       "      <th>regex_label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2025-06-27 07:20:25</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-b9718cd8-f...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1/14/2025 23:07</td>\n",
       "      <td>ModernCRM</td>\n",
       "      <td>Email service experiencing issues with sending</td>\n",
       "      <td>Critical Error</td>\n",
       "      <td>bert</td>\n",
       "      <td>1</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1/17/2025 1:29</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>Unauthorized access to data was attempted</td>\n",
       "      <td>Security Alert</td>\n",
       "      <td>bert</td>\n",
       "      <td>2</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2025-07-12 00:24:16</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-4895c258-b...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2025-06-02 18:25:23</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-ee8bc8ba-9...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2405</th>\n",
       "      <td>2025-08-13 07:29:25</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>nova.osapi_compute.wsgi.server [req-96c3ec98-2...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2406</th>\n",
       "      <td>1/11/2025 5:32</td>\n",
       "      <td>ModernHR</td>\n",
       "      <td>User 3844 account experienced multiple failed ...</td>\n",
       "      <td>Security Alert</td>\n",
       "      <td>bert</td>\n",
       "      <td>7</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2407</th>\n",
       "      <td>2025-08-03 03:07:47</td>\n",
       "      <td>ThirdPartyAPI</td>\n",
       "      <td>nova.metadata.wsgi.server [req-b6d4a270-accb-4...</td>\n",
       "      <td>HTTP Status</td>\n",
       "      <td>bert</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2408</th>\n",
       "      <td>11/11/2025 11:52</td>\n",
       "      <td>BillingSystem</td>\n",
       "      <td>Email service affected by failed transmission</td>\n",
       "      <td>Critical Error</td>\n",
       "      <td>bert</td>\n",
       "      <td>1</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2409</th>\n",
       "      <td>12/25/2025 13:21</td>\n",
       "      <td>AnalyticsEngine</td>\n",
       "      <td>Repeated failed login attempts occurred for us...</td>\n",
       "      <td>Security Alert</td>\n",
       "      <td>bert</td>\n",
       "      <td>7</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1903 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                timestamp           source  \\\n",
       "0     2025-06-27 07:20:25        ModernCRM   \n",
       "1         1/14/2025 23:07        ModernCRM   \n",
       "2          1/17/2025 1:29  AnalyticsEngine   \n",
       "3     2025-07-12 00:24:16         ModernHR   \n",
       "4     2025-06-02 18:25:23    BillingSystem   \n",
       "...                   ...              ...   \n",
       "2405  2025-08-13 07:29:25         ModernHR   \n",
       "2406       1/11/2025 5:32         ModernHR   \n",
       "2407  2025-08-03 03:07:47    ThirdPartyAPI   \n",
       "2408     11/11/2025 11:52    BillingSystem   \n",
       "2409     12/25/2025 13:21  AnalyticsEngine   \n",
       "\n",
       "                                            log_message    target_label  \\\n",
       "0     nova.osapi_compute.wsgi.server [req-b9718cd8-f...     HTTP Status   \n",
       "1        Email service experiencing issues with sending  Critical Error   \n",
       "2             Unauthorized access to data was attempted  Security Alert   \n",
       "3     nova.osapi_compute.wsgi.server [req-4895c258-b...     HTTP Status   \n",
       "4     nova.osapi_compute.wsgi.server [req-ee8bc8ba-9...     HTTP Status   \n",
       "...                                                 ...             ...   \n",
       "2405  nova.osapi_compute.wsgi.server [req-96c3ec98-2...     HTTP Status   \n",
       "2406  User 3844 account experienced multiple failed ...  Security Alert   \n",
       "2407  nova.metadata.wsgi.server [req-b6d4a270-accb-4...     HTTP Status   \n",
       "2408      Email service affected by failed transmission  Critical Error   \n",
       "2409  Repeated failed login attempts occurred for us...  Security Alert   \n",
       "\n",
       "     complexity  cluster regex_label  \n",
       "0          bert        0        None  \n",
       "1          bert        1        None  \n",
       "2          bert        2        None  \n",
       "3          bert        0        None  \n",
       "4          bert        0        None  \n",
       "...         ...      ...         ...  \n",
       "2405       bert        0        None  \n",
       "2406       bert        7        None  \n",
       "2407       bert        0        None  \n",
       "2408       bert        1        None  \n",
       "2409       bert        7        None  \n",
       "\n",
       "[1903 rows x 7 columns]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_non_legacy = df_non_regex[df_non_regex.source!=\"LegacyCRM\"]\n",
    "df_non_legacy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "27295bd7ada09140",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:30:59.173856Z",
     "start_time": "2025-01-15T20:30:59.142606Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1903, 7)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_non_legacy.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "566831c64be8ed7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:31:10.610031Z",
     "start_time": "2025-01-15T20:31:07.235690Z"
    }
   },
   "outputs": [],
   "source": [
    "model = SentenceTransformer('all-MiniLM-L6-v2')  # Lightweight embedding model\n",
    "embeddings_filtered = model.encode(df_non_legacy['log_message'].tolist())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "ae5a2c977f0330cd",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:31:15.767984Z",
     "start_time": "2025-01-15T20:31:15.757908Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1903"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(embeddings_filtered)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "a9b0c2b8798c9247",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:32:19.597483Z",
     "start_time": "2025-01-15T20:32:19.566230Z"
    }
   },
   "outputs": [],
   "source": [
    "X = embeddings_filtered\n",
    "y = df_non_legacy['target_label'].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "b831de9df6a1d4c4",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:32:24.546133Z",
     "start_time": "2025-01-15T20:32:24.357812Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                precision    recall  f1-score   support\n",
      "\n",
      "Critical Error       0.91      1.00      0.95        48\n",
      "         Error       0.98      0.89      0.93        47\n",
      "   HTTP Status       1.00      1.00      1.00       304\n",
      "Resource Usage       1.00      1.00      1.00        49\n",
      "Security Alert       1.00      0.99      1.00       123\n",
      "\n",
      "      accuracy                           0.99       571\n",
      "     macro avg       0.98      0.98      0.98       571\n",
      "  weighted avg       0.99      0.99      0.99       571\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import classification_report\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)\n",
    "clf = LogisticRegression(max_iter=1000)\n",
    "clf.fit(X_train, y_train)\n",
    "y_pred = clf.predict(X_test)\n",
    "report = classification_report(y_test, y_pred)\n",
    "print(report)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "1317f9b2de813a32",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-15T20:36:52.942021Z",
     "start_time": "2025-01-15T20:36:52.910539Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['../models/log_classifier.joblib']"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import joblib\n",
    "joblib.dump(clf, '../models/log_classifier.joblib')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0ddb2803",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "venv",
   "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.12.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}