Interpretable intrusion detection method based on ensemble learning
Through the integrated learning method, combined with CR-RFE feature selection and hyperparameter optimization of the Stacking model, the problems of data redundancy and complex attacks in the intrusion detection system are solved, achieving efficient intrusion detection and model interpretability, and improving the detection effect. and transparency.
Patent Information
- Application Number
- CN202410780244.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-09-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing intrusion detection systems face data redundancy and high-dimensional problems. It is difficult for a single machine learning algorithm to deal with complex intrusion attacks and lacks interpretability, which affects detection results and transparency.
An ensemble learning-based method is adopted, combined with CR-RFE feature selection, Stacking model and GCSA hyperparameter optimization, and SHAP is used for global and local explanations to improve the feature selection and interpretability of the model.
It effectively reduces the data dimension, improves the accuracy and interpretability of intrusion detection, makes the model decision-making process more transparent, improves user trust, and can better respond to complex network attacks.
Smart Images

Figure CN118713879A
Abstract
Description
Technical Field
[0001] The invention relates to a classification method, in particular to an explainable intrusion detection method based on ensemble learning, and belongs to the technical field of network intrusion detection. Background Art
[0002] With the rapid development of information technology, cyberspace security issues are becoming increasingly severe. Traditional network firewalls are no longer sufficient to deal with these threats. As an effective means of protecting the security of information systems, intrusion detection systems play a key role. However, current intrusion detection systems face many challenges. First, there are problems with data redundancy and irrelevant features in intrusion data, which seriously affect the availability of data and pose a serious threat to detection models. In addition, as the complexity of intrusion attacks grows exponentially, a single machine learning algorithm often has difficulty achieving good intrusion detection classification results. Finally, although the model achieves very high accuracy, it cannot provide any information about the reasons behind its decisions and lacks explainability. Summary of the invention
[0003] The present invention is aimed at the problems existing in the prior art and provides an interpretable intrusion detection method based on ensemble learning. In order to solve the problems of excessively high dimensions and data redundancy in intrusion detection data, the present invention proposes a feature selection method called CR-RFE, which integrates three feature selection methods: CFS, which belongs to the filtering method, RF, which belongs to the embedding method, and RFE, which belongs to the wrapping method. In order to solve the problem that a single machine learning algorithm is difficult to cope with increasingly complex intrusion attacks, the present invention designs a Stacking model, in which the first-layer base learner is XGBoost, random forest and support vector machine, the second-layer meta-learner is logistic regression, and GCSA is used to optimize the hyperparameters of the Stacking model. In order to solve the problem of lack of transparency and interpretability of the model, the present invention uses SHAP to globally and locally interpret the prediction results of the model.
[0004] In order to achieve the above objectives, the specific technical scheme of the present invention is as follows: an explainable intrusion detection method based on ensemble learning, the method comprising the following steps:
[0005] Step 1: Data collection: Use the network packet capture tool wireshark or tcpdump to capture the network traffic to be detected and save it in pcap file format. Use the traffic feature extraction tool CICFlowMeter to parse the pcap file traffic data, convert it into the model input format, and save it as a csv file.
[0006] Step 2: Data preprocessing, preprocessing the data collected in step 1;
[0007] Step 3: Feature selection, perform feature selection on the data preprocessed in step 2;
[0008] Step 4: Train the ensemble learning Stacking model and adjust the hyperparameters using the crow search algorithm improved by the genetic algorithm;
[0009] Step 5: Result output: Based on the Stacking model trained in step 4, the target network traffic data is input and the intrusion detection classification result is output;
[0010] Step 6: Result interpretation, based on the intrusion detection classification results output in step 5, SHAP is used for global interpretation and local interpretation. The global interpretation reveals the working mode and important features of the model by analyzing the prediction results of the model on the entire dataset, while the local interpretation focuses on the decision-making process of the model for a single test sample and provides a detailed explanation for the prediction results.
[0011] As an improvement of the present invention, step 2 is as follows: data preprocessing includes three aspects: data cleaning, data encoding, and data standardization. Data cleaning detects whether there are missing data, NaN, and infinite values in the data collected in step 1, which may have a significant impact on the performance of the model. The isnull and sum functions are used to identify these values in each column, and the rows containing these missing values, infinite values, and NaN values are deleted; data encoding uses the binarization technology of the one-hot encoding method to encode the original category features and convert the original category features into numerical values so that the subsequent network can process these features; data standardization StandardScaler function, which will independently standardize each feature by subtracting the mean of each feature and then dividing it by its standard deviation, so that its mean is 0 and its standard deviation is 1. The specific calculation formula is as follows:
[0012]
[0013] Among them, x j ′ is the standardized eigenvalue, x j is the original eigenvalue, μ j is the mean of the feature, σ j is the standard deviation of the feature.
[0014] As another improvement of the present invention, step 3 is as follows: first, the importance of the features output by CFS in the filtering method and RF in the embedding method is ranked, and the top 20% of the features are selected as feature subsets by Pareto analysis. Then, the best feature subset is further selected by the union of the feature subsets selected by the two methods through RFE in the wrapping method.
[0015] As another improvement of the present invention, step 4 is as follows: first, a two-layer Stacking model is designed based on ensemble learning, wherein the first layer of base learners is XGBoost, random forest and support vector machine, and the second layer of meta learner is logistic regression. Since the Stacking model involves a combination of multiple base learners, its performance is highly dependent on the parameter settings of each base learner. The default parameters often cannot give full play to the full potential of the model, so it is particularly important to optimize the hyperparameters. In order to effectively optimize these parameters, the present invention proposes a genetic algorithm improved crow search algorithm (Genetic Crow Search Algorithm, hereinafter referred to as GCSA), the GCSA algorithm enhances the global search capability by introducing a genetic algorithm (Genetic Algorithm, hereinafter referred to as GA), effectively breaks the crow search algorithm (Crow Search Algorithm, hereinafter referred to as CSA) is easily trapped in the local optimum, and improves the efficiency of parameter optimization and the final performance of the model.
[0016] As another improvement of the present invention, step 6 is specifically as follows: in a complex ensemble learning model, the calculation of the SHAP value is based on the concept of Shapley value in cooperative game theory, taking into account the average contribution of each feature to all possible feature combinations. For a specific prediction, the SHAP value is calculated by the following formula:
[0017]
[0018] where φ i (f) is the SHAP value of feature i, f(S) is the model output for a given feature subset S, N is the set of all features, and |S| represents the size of the set S. The positive or negative SHAP value indicates the positive or negative impact of the feature on the model output, while the value indicates the relative degree of contribution. By analyzing the SHAP value, we can identify the key features and have a more comprehensive understanding of the decision-making process of the model.
[0019] Compared with the prior art, the advantages of the present invention are as follows: the feature selection algorithm proposed in the present invention can improve the classification effect while reducing the data dimension. In addition, the technical solution applies the interpretable integrated learning strategy to the network intrusion detection problem. The proposed GCSA algorithm-optimized Stacking model is superior to the traditional machine learning algorithm in terms of accuracy, precision, recall and F1 score, indicating that the model has good performance in the network intrusion detection task and greatly improves the detection efficiency; at the same time, the detection model has good interpretability, and through global and local interpretations, the decision-making process of the model is made more transparent, which improves the user's trust in the model prediction results. The present invention can more efficiently deal with the huge amount of data and multiple complex attack mode problems in network intrusion detection in the real world, as well as the problem that the traditional machine learning-based intrusion detection model lacks interpretability and it is difficult for users to understand the decision-making process of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is the overall flow chart of the present invention;
[0021] Figure 2 Flowchart for feature selection;
[0022] Figure 3 It is the Stacking structure diagram;
[0023] Figure 4 This is the flow chart of the GCSA algorithm. DETAILED DESCRIPTION
[0024] In order to deepen the understanding of the present invention, the present embodiment is described in detail below with reference to the accompanying drawings.
[0025] Example 1: See Figure 1 , an explainable intrusion detection method based on ensemble learning, the method comprising the following steps:
[0026] Step 1: Data collection: Use the network packet capture tool wireshark or tcpdump to capture the network traffic to be detected and save it in pcap file format. Use the traffic feature extraction tool CICFlowMeter to parse the pcap file traffic data, convert it into the model input format, and save it as a csv file.
[0027] Step 2: Data preprocessing, preprocessing the data collected in step 1;
[0028] Step 3: Feature selection, perform feature selection on the data preprocessed in step 2;
[0029] Step 4: Train the ensemble learning Stacking model and adjust the hyperparameters using the crow search algorithm improved by the genetic algorithm;
[0030] Step 5: Result output: Based on the Stacking model trained in step 4, the target network traffic data is input and the intrusion detection classification result is output;
[0031] Step 6: Result interpretation, based on the intrusion detection classification results output in step 5, SHAP is used for global interpretation and local interpretation. The global interpretation reveals the working mode and important features of the model by analyzing the prediction results of the model on the entire dataset, while the local interpretation focuses on the decision-making process of the model for a single test sample and provides a detailed explanation for the prediction results.
[0032] Among them, step 2 is as follows. Data preprocessing includes three aspects: data cleaning, data encoding and data standardization. Data cleaning detects whether there are missing data, NaN and infinite values in the data collected in step 1, which may have a significant impact on the performance of the model. Use isnull and sum functions to identify these values in each column, and delete the rows containing these missing values, infinite values and NaN values; data encoding uses the binarization technology of the one-hot encoding method to encode the original category features and convert the original category features into numerical values so that the subsequent network can process these features; data standardization StandardScaler function, which will independently standardize each feature by subtracting the mean of each feature and then dividing it by its standard deviation, so that its mean is 0 and its standard deviation is 1. The specific calculation formula is as follows:
[0033]
[0034] Among them, x j ′ is the standardized eigenvalue, x j is the original eigenvalue, μ j is the mean of the feature, σ j is the standard deviation of the feature.
[0035] Among them, step 3 is as follows: first, the importance of the output features of CFS in the filtering method and RF in the embedding method are ranked, and the top 20% of the features are selected as the feature subset using Pareto analysis. Then, the best feature subset is further selected by the union of the feature subsets selected by the two methods through RFE in the wrapping method. The detailed process is as follows: Figure 2 shown.
[0036] Among them, step 4 is as follows: first, a two-layer Stacking model is designed based on ensemble learning, such as Figure 3As shown, the first layer of base learners are XGBoost, random forest and support vector machine, and the second layer of meta learner is logistic regression. Since the Stacking model involves a combination of multiple base learners, its performance is highly dependent on the parameter settings of each base learner. The default parameters often cannot give full play to the full potential of the model, so it is particularly important to optimize the hyperparameters. In order to effectively optimize these parameters, the present invention proposes a genetic algorithm-improved crow search algorithm (Genetic CrowSearch Algorithm, hereinafter referred to as GCSA). The GCSA algorithm enhances the global search capability by introducing a genetic algorithm (Genetic Algorithm, hereinafter referred to as GA), effectively breaking the limitation of the crow search algorithm (CrowSearch Algorithm, hereinafter referred to as CSA) that is easily trapped in the local optimum, thereby improving the efficiency of parameter optimization and the final performance of the model. Figure 4 The model training uses the public dataset CIC-IDS2017. The pseudo code of the GCSA algorithm is as follows, where r i is a random number between 0 and 1, x it represents the position of crow i in the tth iteration,
[0037]
[0038]
[0039] Among them, step 6 is as follows. In complex ensemble learning models, the calculation of SHAP value is based on the concept of Shapley value in cooperative game theory, which considers the average contribution of each feature to all possible feature combinations. For a specific prediction, SHAP value is calculated by the following formula:
[0040]
[0041] where φ i (f) is the SHAP value of feature i, f(S) is the model output for a given feature subset S, N is the set of all features, and |S| represents the size of the set S. The positive or negative SHAP value indicates the positive or negative impact of the feature on the model output, while the value indicates the relative degree of contribution. By analyzing the SHAP value, we can identify the key features and have a more comprehensive understanding of the decision-making process of the model.
[0042] Embodiment 2: A terminal comprises a processor, a memory and a program of an interpretable intrusion detection method based on ensemble learning stored in the memory. When the interpretable intrusion detection method based on ensemble learning is executed by the processor, the steps of the interpretable intrusion detection method based on ensemble learning are performed.
[0043] Embodiment 3: A computer-readable storage medium stores computer instructions, which, when executed by a processor, implement the steps of an explainable intrusion detection method based on ensemble learning.
[0044] It should be noted that the above embodiments are not intended to limit the protection scope of the present invention, and equivalent changes or substitutions made on the basis of the above technical solutions all fall within the protection scope of the claims of the present invention.
Claims
1. An explainable intrusion detection method based on ensemble learning, characterized in that: The method comprises the following steps: Step 1: Data collection: Use the network packet capture tool wireshark or tcpdump to capture the network traffic to be detected and save it in pcap file format. Use the traffic feature extraction tool CICFlowMeter to parse the pcap file traffic data, convert it into the model input format, and save it as a csv file. Step 2: Data preprocessing, preprocessing the data collected in step 1; Step 3: Feature selection, perform feature selection on the data preprocessed in step 2; Step 4: Train the ensemble learning Stacking model and adjust the hyperparameters using the crow search algorithm improved by the genetic algorithm; Step 5: Result output: Based on the Stacking model trained in step 4, the target network traffic data is input and the intrusion detection classification result is output; Step 6: Result interpretation. Based on the intrusion detection classification results output in step 5, SHAP is used for global interpretation and local interpretation. The global interpretation reveals the working mode and important features of the model by analyzing the prediction results of the model on the entire dataset, while the local interpretation focuses on the decision-making process of the model for a single test sample and provides a detailed explanation for the prediction results.
2. The explainable intrusion detection method based on ensemble learning according to claim 1, characterized in that: Step 2 is as follows: data preprocessing includes data cleaning, data encoding, and data standardization. Data cleaning detects whether there are missing data, NaN, and infinite values in the data collected in step 1, uses isnull and sum functions to identify these values in each column, and deletes the rows containing these missing values, infinite values, and NaN values; data encoding uses the binarization technology of the one-hot encoding method to encode the original category features and convert the original category features into numerical values so that the subsequent network can process these features; The data standardization StandardScaler function will standardize each feature independently by subtracting the mean of each feature and then dividing it by its standard deviation so that its mean is 0 and its standard deviation is 1. The specific calculation formula is as follows: Among them, x j ′ is the standardized eigenvalue, x j is the original eigenvalue, μ j is the mean of the feature, σ j is the standard deviation of the feature.
3. The explainable intrusion detection method based on ensemble learning according to claim 1, characterized in that: Step 3 is as follows: first, the feature importance ranking is output by Correlation Feature Selection (CFS) in the filtering method and Random Forest (RF) in the embedding method, and the top 20% of the features are selected as the feature subset using Pareto analysis. Then, the union of the feature subsets selected by the two methods is further screened out to obtain the best feature subset through Recursive Feature Elimination (RFE) in the wrapping method.
4. The explainable intrusion detection method based on ensemble learning according to claim 1, characterized in that: Step 4 is as follows: First, a two-layer Stacking model is designed based on ensemble learning. The first-layer base learners are XGBoost, random forest and support vector machine, and the second-layer meta-learner is logistic regression. Since the Stacking model involves a combination of multiple base learners, its performance is highly dependent on the parameter settings of each base learner. The default parameters often cannot fully tap the full potential of the model, so hyperparameter optimization is particularly important.
5. The explainable intrusion detection method based on ensemble learning according to claim 1, characterized in that: Step 6 is as follows. In complex ensemble learning models, the calculation of the SHAP value is based on the concept of Shapley value in cooperative game theory, which considers the average contribution of each feature to all possible feature combinations. For a specific prediction, the SHAP value is calculated by the following formula: where φ i (f) is the SHAP value of feature i, f(S) is the model output for a given feature subset S, N is the set of all features, |S| represents the size of the set S, the positive or negative value of the SHAP value represents the positive or negative impact of the feature on the model output, and the value represents the relative degree of contribution. By analyzing the SHAP value, we can identify the key features and thus have a more comprehensive understanding of the decision-making process of the model.
6. A terminal, characterized in that: The invention comprises a processor, a memory and a program of an interpretable intrusion detection method based on ensemble learning stored in the memory. When the interpretable intrusion detection method based on ensemble learning is executed by the processor, the steps of the interpretable intrusion detection method based on ensemble learning as described in any one of claims 1 to 6 are implemented.
7. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed by a processor, the steps of the explainable intrusion detection method based on ensemble learning as described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Industrial internet intrusion detection model optimization feature selection method
CN117411675A
Asphalt pavement rut depth prediction method based on interpretable ensemble learning
CN117874509A
Network intrusion analysis method based on interpretable artificial intelligence technology
CN117997624A
Cited By
Deep learning model analysis method and system for new energy power generation output prediction
CN119398341A
A Deep Learning Model Analysis Method and System for Predicting New Energy Power Generation Output
CN119398341B
Vertical federated learning method, vertical federated learning server, and vertical federated learning client
WO2026186042A1
