A network anomaly detection method integrating GBDT and neural network

By integrating GBDT with neural networks and combining TabTransformer and Focal Loss loss functions, the problem of insufficient learning of categorical and numerical features and data imbalance in tabular data is solved, thereby improving the network's anomaly detection performance.

CN114169390BActive Publication Date: 2024-11-05INSTITUTE OF INFORMATION ENGINEERING CHINESE ACADEMY OF SCIENCES
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111231657.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-22
Publication Date
2024-11-05
Estimated Expiration
2041-10-22

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively learn categorical and numerical features from tabular data, and suffer from class imbalance in network anomaly detection, causing the model to favor the majority class and affecting the recognition of the minority class.

Method used

We adopt an integrated GBDT and neural network approach. By processing class features through TabTransformer and combining GBDT2NN technology, we represent the pre-trained GBDT model as a neural network and fuse them into a unified model. We also introduce Focal Loss loss function and adaptive learning strategy to optimize the model's ability to identify minority classes.

Benefits of technology

Effectively learn the categorical and numerical features in tabular data, alleviate data imbalance, improve the model's ability to identify minority classes, and enhance overall detection performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114169390B_ABST
    Figure CN114169390B_ABST
Patent Text Reader

Abstract

The present invention discloses a network anomaly detection method integrating GBDT and neural network, which belongs to the cross-technical field of network information security and machine learning. In order to overcome the deficiencies of traditional machine learning algorithms and deep learning algorithms in processing tabular data in network anomaly detection tasks, the present invention selects a TabTransformer structure designed specifically for tabular data. At the same time, in order to cope with the category imbalance problem in network anomaly detection, the present invention adopts the cost-sensitive idea, introduces the Focal Loss loss function designed specifically for the imbalance problem, adopts an adaptive learning strategy, and automatically selects the optimal parameters of Focal Loss from the parameter search space. The present invention is applicable to both binary classification problems and multi-classification problems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Aiming at the network anomaly detection task in the scenario of unbalanced data categories and tabular data input, the present invention designs a network anomaly detection method integrating GBDT and neural network, which belongs to the interdisciplinary technical field of network information security and machine learning. Background Art

[0002] Nowadays, with the rapid development of the Internet, the frequency of cyberspace attacks and other threats is on the rise, and cyberspace security has become one of the issues that need to be focused on in our daily lives. Network Anomaly Detection (NAD) aims to detect malicious traffic in the network and distinguish normal traffic from potential network attack traffic by observing network traffic data. It is an indispensable part of cyberspace security practice. Nowadays, traditional machine learning and advanced deep learning methods have been widely used in the field of network anomaly detection and have gradually become mainstream methods.

[0003] At present, conventional network anomaly detection usually takes structured tabular data as input, and the tabular data contains both discrete categorical features and continuous numerical features. Therefore, the classification model must be able to effectively learn tabular data and treat the two different types of features reasonably. On the one hand, traditional machine learning methods, such as gradient boosting decision tree (GBDT), have a good effect when processing tabular data, mainly reflected in its better learning ability for continuous numerical features, can automatically select and combine useful numerical features, and effectively construct decision trees by calculating information gain. However, since categorical features are generally converted into high-dimensional sparse one-hot encoding, GBDT will obtain very little information gain when processing such data and cannot effectively learn such features. On the other hand, the advantage of deep learning methods (such as neural networks) lies mainly in its ability to process high-dimensional sparse categorical features, and can efficiently represent categorical features by learning parameter embedding. However, dense numerical features often lead to very complex optimization parameters for neural networks and are prone to falling into local optimality. Therefore, deep learning methods are not as effective as traditional machine learning when processing numerical features. In general, traditional machine learning methods and deep learning methods have their own advantages and disadvantages when processing tabular data.

[0004] In addition, network anomaly detection also faces the problem of data category imbalance. Most of the data obtained in real scenarios are unbalanced, which is mainly reflected in the fact that the number of attack type samples as the minority class is often far less than the normal samples as the majority class. However, minority class samples are often more significant in practical applications. In the case of data category imbalance, the classification model tends to favor the majority class, thereby misclassifying minority class samples. In this way, the overall effect of the model seems to be good, but the effect on the minority class is poor. The existing solutions to the problem of category imbalance can be mainly divided into three categories: data-level methods, algorithm-level methods, and cost-sensitive methods. However, most data-level methods resample based on the distance between samples, which not only brings a large distance calculation consumption, but may not be applicable to classification features or missing values. Algorithm-level methods usually combine a data-level method with an ensemble learning algorithm to obtain better results, but they also have the disadvantages of time-consuming calculation and easy overfitting or underfitting. Cost-sensitive methods require careful design of classification costs, usually combined with effective loss functions. The published Chinese invention patent CN112200316A discloses a GBDT learning method for online prediction tasks. By combining GBDT and deep learning methods, it can improve the training and learning effect of the GBDT tree model on the tabular data space and maintain efficient online update capabilities. However, it is not specifically aimed at network anomaly detection and cannot solve the problem of data imbalance.

[0005] In summary, effectively learning tabular data and overcoming the class imbalance problem are two urgent issues to be solved in the field of network anomaly detection. However, most of the existing research on network anomaly detection does not focus on these two issues at the same time. Summary of the invention

[0006] In order to overcome the deficiencies of traditional machine learning algorithms and deep learning algorithms in processing tabular data in network anomaly detection tasks, the present invention proposes a network anomaly detection method that integrates GBDT and neural networks, which can make full use of the advantages of neural networks in processing category features and the advantages of GBDT in processing numerical features. Among them, the neural network of the present invention uses the TabTransformer structure designed specifically for tabular data. At the same time, in order to cope with the category imbalance problem in network anomaly detection, the present invention adopts the cost-sensitive idea, introduces the Focal Loss loss function designed specifically for the imbalance problem, and adopts an adaptive learning strategy to automatically select the optimal parameters of Focal Loss from the parameter search space. In addition, the present invention is applicable to both binary classification problems and multi-classification problems.

[0007] In order to achieve the above object, the technical solution of the present invention is as follows:

[0008] A network anomaly detection method integrating GBDT and neural network includes the following steps:

[0009] 1) Produce training data labeled with normal traffic and abnormal traffic, the training data includes discrete category features and continuous numerical features, the category features include protocol type, port number and application layer protocol, the numerical features include flow duration, number of uplink and downlink packets and number of uplink and downlink bytes;

[0010] 2) Preprocess the training data: remove the IP address field in the data, encode the categorical features into recognizable digital form, and scale the numerical features according to the standardization operation;

[0011] 3) Input the category features of the training data into the neural network model TabTransformer for learning to obtain the original output of the model; input the numerical features into the gradient boosting decision tree GBDT for modeling learning to obtain a preliminarily trained GBDT model; use the GBDT2NN technology to represent the pre-trained GBDT model as a neural network, merge GBDT and TabTransformer into a classification model, and weight the original output of the neural network and the output of TabTransformer to form the overall output value of the model, and then obtain the overall prediction result given by the classification model through the activation function;

[0012] 4) Use the preprocessed training data to train the classification model, use Focal Loss as the loss function to guide the training process, and perform multiple rounds of learning through adaptive learning to search for the best parameters to obtain a trained classification model;

[0013] 5) Accepting the network traffic data to be classified for the preprocessing, and then inputting it into the trained classification model for classification to detect network anomalies.

[0014] Furthermore, the neural network model TabTransformer deletes the Normalization layer and the Concatenation layer on the original TabTransformer network architecture.

[0015] Furthermore, after the category features in step 3) are input into TabTransformer, the high-dimensional sparse one-hot vector is first converted into a low-dimensional dense embedding representation through the Embedding technology.

[0016] Furthermore, the low-dimensional dense embedding representation is processed by a Transformer layer and then input into a multi-layer perceptron to output the original output.

[0017] Furthermore, the classification in step 5) includes binary classification and multi-classification. Binary classification means that the classified categories include normal categories and attack categories; multi-classification means that the classified categories include normal categories and multiple attack categories, and the multiple attack categories include at least one of denial of service attacks and detection attacks.

[0018] The present invention provides a network anomaly detection method integrating GBDT and neural network, which is characterized in that GBDT and TabTransformer are used to process category features and numerical features respectively, and the pre-trained GBDT model is represented as a neural network through GBDT2NN technology. On the premise of fully retaining the performance of the GBDT model, it is integrated with TabTransformer into a unified neural network model, rather than giving category predictions separately and then weighted voting. Therefore, in end-to-end training, the problem of data imbalance can be optimized by introducing Focal Loss, an advanced loss function, to effectively enhance the model's recognition ability for minority classes. At the same time, the model hyperparameters can be automatically determined in combination with an adaptive learning strategy. Compared with the prior art, the present invention has the following positive effects:

[0019] 1. The present invention proposes a network anomaly detection method that integrates GBDT and neural network, which can effectively learn the category features and numerical features in tabular data.

[0020] 2. The present invention aims at the data imbalance problem in network anomaly detection and uses Focal Loss to guide the model training process, which can effectively reduce the bias towards the majority class and compensate for the degradation of the classification model in the data imbalance scenario.

[0021] 3. The present invention designs an adaptive learning framework that can automatically determine the optimal model parameters without prior knowledge.

[0022] 4. The present invention uses the public KDD99 and UNSW-NB15 datasets to evaluate the proposed new model. The experimental results show that the method of the present invention outperforms other advanced methods in both multi-classification and binary classification scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 This is the overall architecture diagram of the network anomaly detection integrating GBDT and neural network of the present invention.

[0024] Figure 2 The following is a schematic diagram of the TabTransformer architecture.

[0025] Figure 3 It is the MCC value under different imbalance ratios in the binary classification experiment. DETAILED DESCRIPTION

[0026] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly and completely describe the technical solution of the present invention. The specific embodiments described here are only used to explain the present invention and are not used to limit the present invention.

[0027] Figure 1 The overall structure diagram of the present invention is as follows:

[0028] Step 1) Data preprocessing

[0029] At the data level, the traffic generated by network communication is usually divided in the form of streams or sessions, where a session can represent bidirectional flow information and is identified using a five-tuple (source IP, source port, destination IP, destination port, transport layer protocol type). The data used in the present invention is structured session information given in a tabular form, including category features such as protocol type, port number, application layer protocol, and flow duration, number of uplink and downlink packets, and number of uplink and downlink bytes for each session. Each flow is marked as normal traffic or a specific type of attack traffic. At the same time, the data is divided into a training set and a test set. For the data in the training set and the test set, considering that network attacks may come from any IP address, the IP address is not suitable for training as a feature, so the IP address field in the data is deleted. Since most category features may be in the form of strings, they are encoded as numbers (1, 2, 3...) that can be recognized by the model; for numerical features, standardized operations are taken for scaling.

[0030] For the original data (including training set and test set), unnecessary IP address features are removed, categorical features are numerically encoded, and numerical features are standardized. Finally, the data set D = {(x i ,y i ),y i ∈[0,classnum),i=1,2,…,N}(where x i is the feature vector of each session, y is the i The corresponding label, classnum is the number of categories, N is the number of samples) distinguishes different types of features and divides the data into categorical features x cat and numerical features x cont .

[0031] Step 2) TabTransformer processes categorical features

[0032] In order to effectively process tabular data, the present invention treats discrete categorical features and continuous numerical features differently. The present invention uses TabTransformer to learn categorical features. As a neural network model, TabTransformer takes categorical features as its input, obtains a new representation of categorical features through Embedding technology, and then uses Transformer technology to finally give the original output of the model through a multi-layer perceptron. The overall architecture of the original TabTransformer is as follows: Figure 2 As shown in the figure, it takes both categorical features and numerical features as inputs, but the original structure is not fully adopted in the present invention. In order to fully utilize the ability of TabTransformer to process categorical features, the present invention only uses the part of the TabTransformer structure for categorical features, and deletes the Normalization layer and Concatenation layer for numerical features. In order to learn categorical features more effectively, before entering the Transformer layer, the categorical features are converted from high-dimensional sparse one-hot vectors into low-dimensional dense embedding representations through the Embedding technology, as shown in Formula (1), where x i represents the i-th category feature, m is the total number of category features, Then x i The corresponding learnable embedding representation, E φ (x cat ) is the result of embedding all category features.

[0033]

[0034] The first Transformer layer is E φ (x cat ) as input, and pass the output to the second Transformer layer, and so on until the Nth Transformer layer. As shown in (2), the output of the Nth Transformer layer will be directly input into a multi-layer perceptron In the above example, we get the original output value y of the model. TabTransformer . Where θ1 and θ2 are the model parameters of the multi-layer perceptron and Transformer layers respectively.

[0035]

[0036] Step 3) GBDT2NN processes numerical features

[0037] For numerical features, the present invention uses GBDT to model and learn continuous numerical features to obtain a preliminarily trained GBDT model. In order to make full use of the prediction values ​​given by the pre-trained GBDT model and the structural information of the decision tree, GBDT2NN is used to distill the decision tree in GBDT into a neural network model. By using the powerful expression ability of the neural network, the decision function and tree structure of GBDT can be perfectly approximated. For a single tree t, it can be expressed in the form of formula (3). Among them, the neural network One-hot representation of leaf node index used to fit the tree model; x[I t ] is a neural network Input, I t Represents the index of the numerical feature used when building this tree; q t Represents the value of the leaf node of the tree; θ represents the neural network Parameters of the network; the output y of the network t It is a mapping between leaf node index and leaf node value.

[0038]

[0039] Since the GBDT model generates many decision trees, it is very inefficient to construct a neural network such as (3) for each tree. Therefore, according to the GBDT2NN neural network model, all trees are divided into k groups, and each group T has trees, m is the number of decision trees in the pre-trained GBDT model. The output of GBDT2NN can finally be expressed as formula (4). Represents the output of the jth group of trees x[I T ] is a neural network Input, I T Represents the index of the numerical feature used when building this group of decision trees, θ T Represents the neural network corresponding to this group of decision trees Parameters.

[0040]

[0041] Step 4) Fusion of GBDT2NN and TabTransformer

[0042] In order to integrate GBDT and TabTransformer into a unified model for end-to-end training, the pre-trained GBDT model is represented as a neural network using GBDT2NN technology, and the output of the network is weighted and summed with the output of TabTransformer to obtain the overall output of the model. GBDT2NN With y TabTransformerCombined to obtain the prediction of the entire model and perform end-to-end training, the present invention assigns different weights w1 and w2 to the output values ​​of the two modules (the two weights can be learned through back-propagation training), and the prediction probability of the final model output is As shown in formula (5), σ represents the activation function (sigmoid for binary classification and softmax for multi-classification).

[0043]

[0044] Step 5) Train the classification model based on Focal Loss

[0045] The model is trained using preprocessed data, and Focal Loss is used as the loss function to guide the training process. Focal Loss can make the model pay more attention to minority class samples that are difficult to classify and reduce the bias caused by the majority class.

[0046] According to formula (5), the loss of the model can be expressed as formula (6): Represents the loss function, and y is the true label of sample x.

[0047]

[0048] In order to deal with the problem of data category imbalance, this paper adopts the cost-sensitive idea and introduces FocalLoss as the loss function of the model. Focal Loss was originally used to solve the problem of category imbalance in target detection tasks and is an improvement on the traditional cross entropy loss. This paper introduces it into the field of network anomaly detection. For the binary classification problem, Focal Loss can be expressed as formula (7), where is the probability prediction defined in equation (5), y i is the label of the input sample, α is the balancing factor, and γ ≥ 0 is called the focusing parameter.

[0049]

[0050] For multi-classification problems, we can adopt the one-vs-all idea to expand formula (7) into formula (8), where y is the one-hot representation of the category label, It is a probability output of the form (m,n) (m is the number of samples, n is the number of categories).

[0051]

[0052] Based on the loss functions defined in equations (7) and (8), we can perform end-to-end model training and use the gradient descent method to select the model with the smallest loss.

[0053] In order to determine the appropriate balance factor α and focus parameter γ, the present invention also constructs an adaptive learning framework, constructs a search space for α and γ, assigns different parameter combinations to Focal Loss, and specifies a performance indicator, such as the F1 score, so that the optimal parameters for achieving the best performance can be automatically obtained, effectively avoiding the need for expert knowledge to set appropriate parameters. Specifically, the present invention limits α and γ to [0.25, 0.75] and [0.5, 5] respectively. Step 6) Predict the test set

[0054] Input the test set, use the trained classification model to classify all test samples, and calculate the evaluation index. The present invention is applicable to both multi-classification and binary classification scenarios. In the multi-classification scenario, in addition to the normal category, there are also multiple attack types, such as denial of service attacks, detection attacks, etc., and the number of each category is uneven; in the binary classification scenario, all types of attacks are regarded as attack categories, and the rest are normal categories.

[0055] Compared with the technical solution adopted by the disclosed Chinese invention patent CN112200316A, the method proposed by the present invention is innovative in the following aspects: (1) The input data method of the present invention is different from that of CN 112200316A. The present invention focuses on different types of features in tabular data, treats categorical features and numerical features differently, and uses different models for learning; in the GBDT part, the present invention only uses categorical features as input; and for numerical features, the present invention uses TabTransformer for learning; while in CN112200316A, these two types of features are simultaneously input into GBDT. (2) In the leaf index vector embedding part, CN112200316A only uses a neural network with two fully connected layers, while the present invention does not limit the model structure used to implement leaf index vector embedding, and the number of neural network layers can be specified as needed. (3) The present invention focuses on the problem of data imbalance, which is not considered in CN112200316A. The present invention solves the imbalance problem by introducing Focal Loss, which can effectively avoid the classification model from being biased towards the majority class and alleviate the problem of model performance degradation caused by class imbalance.

[0056] To illustrate the effectiveness of the present invention, the KDD99 dataset and the UNSW-NB15 dataset were used as model inputs for testing and compared with other advanced methods. After removing unnecessary features such as IP addresses from the KDD99 dataset, there are 7 category features and 34 numerical features. DoS category samples occupy the majority of the KDD99 dataset, which is the majority class, and the remaining categories are minority classes. After removing unnecessary features such as IP addresses from the UNSW-NB15 dataset, there are 5 category features and 37 numerical features, including a total of 9 attack types (Reconnaissance, Backdoor, DoS, etc.). In the UNSW-NB15 dataset, the normal traffic category is the majority class, and other attack categories are minority classes.

[0057] In terms of comparison methods, this test uses LightGBM as the baseline, selects two methods designed for tabular data, namely the original TabTransformer and CatBoost, and selects two methods designed for imbalanced problems, namely FLAGB and SPE. The method of the present invention is called GTF.

[0058] For multi-classification scenarios, this test used the KDD99 dataset to conduct experiments, using ROCAUC and MCC as evaluation indicators for the overall effect of the model, and F1 value as the evaluation indicator for a single category. Table 1 shows the comparison results in the multi-classification experiment. The results show that on the KDD99 dataset, GTF is superior to other methods in terms of overall indicators, and significantly improves the baseline in terms of individual indicators of each category. It is superior to other methods in three categories and can improve the effect on minority classes.

[0059] Table 1 KDD99 multi-classification experimental results

[0060]

[0061] For the binary classification scenario, this test uses the UNSW-NB15 dataset, considering only the normal and attack categories, and processes the attack category through random undersampling technology, constructing different imbalance ratios (ImbalanceRatio, IR), which are 50, 100, 500, and 1000, respectively, to measure the robustness of the model under different imbalance levels. MCC is used as the evaluation indicator to examine the overall performance of the model. Figure 3 The experimental results of binary classification are shown in Figure 2. The results show that GTF achieves the best results under different imbalance ratios, and as the imbalance ratio increases, the performance of the model decreases less, showing better stability.

[0062] The above experiments all show that the method of the present invention can realize effective network anomaly detection, can well adapt to the problem of imbalance of tabular data and data categories, and the experimental results have reached the standard that can be applied in practice.

[0063] The above embodiments are provided only for the purpose of describing the present invention, and are not intended to limit the scope of the present invention. The scope of the present invention is defined by the appended claims. Various equivalent substitutions and modifications made without departing from the spirit and principles of the present invention should all be included within the scope of the present invention.

Claims

1. A network anomaly detection method integrating GBDT and neural network, characterized in that: The following steps are involved: 1) Produce training data labeled with normal traffic and abnormal traffic, the training data includes discrete category features and continuous numerical features, the category features include protocol type, port number and application layer protocol, the numerical features include flow duration, number of uplink and downlink packets and number of uplink and downlink bytes; 2) Preprocess the training data: remove the IP address field in the data, encode the categorical features into recognizable digital form, and scale the numerical features according to the standardization operation; 3) Input the category features of the training data into the neural network model TabTransformer for learning to obtain the original output of the model; input the numerical features into the gradient boosting decision tree GBDT for modeling learning to obtain a preliminarily trained GBDT model; use the GBDT2NN technology to represent the pre-trained GBDT model as a neural network, merge the GBDT model with the TabTransformer model into a classification model, and perform a weighted summation of the original output of the neural network and the output of the TabTransformer model to form the overall output value of the model, and then obtain the overall prediction result given by the classification model through the activation function; 4) Use the preprocessed training data to train the classification model, use FocalLoss as the loss function to guide the training process, and perform multiple rounds of learning to search for the best parameters through adaptive learning to obtain a trained classification model; 5) Accepting the network traffic data to be classified for the preprocessing, and then inputting it into the trained classification model for classification to detect network anomalies.

2. The method according to claim 1, characterized in that The neural network model TabTransformer deletes the Normalization layer and the Concatenation layer from the original TabTransformer network architecture.

3. The method according to claim 1, characterized in that After the category features in step 3) are input into TabTransformer, the high-dimensional sparse one-hot vector is first converted into a low-dimensional dense embedding representation through the Embedding technology.

4. The method according to claim 3, characterized in that The low-dimensional dense embedding representation is processed through the Transformer layer and then input into a multi-layer perceptron to output the original output.

5. The method according to claim 1, characterized in that The method of using GBDT2NN technology to represent the pre-trained GBDT model as a neural network is as follows: according to the GBDT2NN model structure, all decision trees generated by the GBDT model are divided into k groups, and each group T has decision trees, m is the number of decision trees, and a neural network model is obtained; the output of the neural network model is expressed as: in, Represents the output of the jth group of trees represents a neural network, x[I T ] is a neural network Input, I T Represents the index of the numerical feature used when building this group of decision trees, θ T Represents the neural network corresponding to this group of decision trees Parameters.

6. The method according to claim 1, characterized in that For binary classification, the activation function is sigmoid; for multi-classification, the activation function is softmax.

7. The method according to claim 1, characterized in that For binary classification, the expression of Focal Loss is as follows: in, represents the probability prediction, y i represents the label of the input sample, α represents the balance factor, γ ≥ 0 represents the focusing parameter, m represents the number of samples, and i represents the sample ordinal number.

8. The method according to claim 1, characterized in that For multi-classification, the expression of Focal Loss is as follows: in, represents the probability prediction of (m,n), where m represents the number of samples, n represents the number of categories, and y i represents the label of the input sample, y represents the one-hot representation of the category label, α represents the balance factor, γ ≥ 0 represents the focusing parameter, and i represents the sample ordinal.

9. The method according to claim 7 or 8, characterized in that The method of performing multiple rounds of learning to search for the best parameters through adaptive learning is as follows: construct an adaptive learning framework, build a search space for the two parameters α and γ, assign different parameter combinations to Focal Loss, specify a performance indicator, and automatically obtain the best parameters to achieve the best performance.

10. The method according to claim 1, characterized in that The final classification is binary or multi-classification; binary classification means that the classified categories include normal categories and attack categories; multi-classification means that the classified categories include normal categories and multiple attack categories, and the multiple attack categories include at least one of denial of service attacks and detection attacks.