Deepika wants her server should be free from intruder. She wants to detect whether the received client request is a legitimate or an attack (normal/attack). Design an incursion detection model to help Deepika using Adaboost classifier.


give me python program 


FEATURE SELECTION
rfc = RandomForestClassifier();
Importance of feature in visual plots

# Classification report
# Plotting the confusion matrix with orange colormap
# Confusion Matrix
# Plotting training and test accuracy
# Evaluate the model on training and test accuracy
training and test accuracy and confusion matrix and heat map



Testcsv contains:
duration  protocol_type  service  flag  src_bytes  dst_bytes  land  \
0         0              4      111    12          0          0     0   
1         0              4      111    12          0          0     0   
2         2              4       85    20      12983          0     0   
3         0              3       79    20         20          0     0   
4         1              4      121    13          0         15     0   

   wrong_fragment  urgent  hot  ...  dst_host_count  dst_host_srv_count  \
0               0       0    0  ...             255                  10   
1               0       0    0  ...             255                   1   
2               0       0    0  ...             134                  86   
3               0       0    0  ...               3                  57   
4               0       0    0  ...              29                  86   

   dst_host_same_srv_rate  dst_host_diff_srv_rate  \
0                    0.04                    0.06   
1                    0.00                    0.06   
2                    0.61                    0.04   
3                    1.00                    0.00   
4                    0.31                    0.17   

   dst_host_same_src_port_rate  dst_host_srv_diff_host_rate  \
0                         0.00                         0.00   
1                         0.00                         0.00   
2                         0.61                         0.02   
3                         1.00                         0.28   
4                         0.03                         0.02   

   dst_host_serror_rate  dst_host_srv_serror_rate  dst_host_rerror_rate  \
0                   0.0                       0.0                  1.00   
1                   0.0                       0.0                  1.00   
2                   0.0                       0.0                  0.00   
3                   0.0                       0.0                  0.00   
4                   0.0                       0.0                  0.83   

   dst_host_srv_rerror_rate  
0                      1.00  
1                      1.00  
2                      0.00  
3                      0.00  
4                      0.71  

[5 rows x 41 columns]


Traincsv contains:
duration  protocol_type  service  flag  src_bytes  dst_bytes  land  \
0         0              1       11    10        491          0     0   
1         0              2       36    10        146          0     0   
2         0              1       41     6          0          0     0   
3         0              1       15    10        232       8153     0   
4         0              1       15    10        199        420     0   

   wrong_fragment  urgent  hot  ...  dst_host_srv_count  \
0               0       0    0  ...                  25   
1               0       0    0  ...                   1   
2               0       0    0  ...                  26   
3               0       0    0  ...                 255   
4               0       0    0  ...                 255   

   dst_host_same_srv_rate  dst_host_diff_srv_rate  \
0                    0.17                    0.03   
1                    0.00                    0.60   
2                    0.10                    0.05   
3                    1.00                    0.00   
4                    1.00                    0.00   

   dst_host_same_src_port_rate  dst_host_srv_diff_host_rate  \
0                         0.17                         0.00   
1                         0.88                         0.00   
2                         0.00                         0.00   
3                         0.03                         0.04   
4                         0.00                         0.00   

   dst_host_serror_rate  dst_host_srv_serror_rate  dst_host_rerror_rate  \
0                  0.00                      0.00                  0.05   
1                  0.00                      0.00                  0.00   
2                  1.00                      1.00                  0.00   
3                  0.03                      0.01                  0.00   
4                  0.00                      0.00                  0.00   

   dst_host_srv_rerror_rate    class  
0                      0.00   normal  
1                      0.00   normal  
2                      0.00  anomaly  
3                      0.01   normal  
4                      0.00   normal  

[5 rows x 42 columns]


class: normal (or) anomaly


dataset fetched from https://www.kaggle.com/code/aman1801/network-intrusion-detection-upgraded/input