BP neural network intrusion detection method based on improved chimpanzee optimization algorithm
By improving the chimpanzee optimization algorithm to optimize the initial value of the BP neural network, the problem of slow detection speed and easy to fall into local optimality in network intrusion detection is solved, and higher detection accuracy and lower missed rate are achieved and false positive rate.
Patent Information
- Application Number
- CN202411203259.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-12
AI Technical Summary
The existing network intrusion detection technology has problems such as slow detection speed, poor independent learning ability, and high false alarm rate and missed alarm rate. Because the initial values of BP neural networks are very random and prone to local optimal, it is difficult to effectively detect network intrusion.
Using the BP neural network based on the improved chimpanzee optimization algorithm, the original threshold and weight of the BP neural network are used as the initial population position to optimize, and Piecewise mapping and adaptive factor optimization are used to avoid local optimization and improve the accuracy of the initial value. , and evaluate and iteratively train the model through accuracy and recall to build the optimal intrusion detection model.
It improves the accuracy of network intrusion detection, reduces the missed and false alarm rates, and enhances the stability and efficiency of the detection model.
Smart Images

Figure CN118944959A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of network intrusion detection, in particular to a BP neural network intrusion detection method based on an improved chimpanzee optimization algorithm. Background Art
[0002] In view of the increasingly serious network security issues, simply relying on passive defense technologies such as network firewalls and user authentication systems can no longer completely solve the security challenges of networks and information. As an active defense method, intrusion detection technology can continuously monitor computer and network behaviors in the network. It can not only monitor malicious behaviors from outside the network, but also detect unauthorized and malicious behaviors within the network system. Through specific technical means, intrusion detection technology collects network logs, monitors network communications, and analyzes these logs and data packets to detect whether there are malicious behaviors in the network that may damage network communications.
[0003] The challenges of network intrusion detection are mainly slow detection speed, poor autonomous learning ability, and high false alarm and missed alarm rates. Improving detection speed and accuracy is a key research issue. Neural network algorithms have the advantages of self-adaptation, self-organization, self-learning, strong generalization ability, and large-scale computing. Therefore, they are suitable for the current complex and changeable intrusion detection environment. BP neural network can achieve better results than traditional intrusion detection, but BP neural network has the disadvantages of large randomness of initial values and easy to fall into local optimality. Therefore, we propose a BP neural network intrusion detection method based on the improved chimpanzee optimization algorithm to solve the above problems. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] In view of the deficiencies of the prior art, the present invention provides a BP neural network intrusion detection method based on an improved chimpanzee optimization algorithm, which solves the problems raised in the above background technology.
[0006] (II) Technical solution
[0007] In order to achieve the above-mentioned purpose, the present invention specifically adopts the following technical solutions:
[0008] A BP neural network intrusion detection method based on an improved chimpanzee optimization algorithm comprises the following steps:
[0009] S1: Construct a BP neural network and determine the number of nodes in the input layer, hidden layer, and output layer of the BP neural network;
[0010] S2: The original threshold and original weight of the BP neural network are used as the initial population position of the chimpanzee optimization algorithm to find the optimal initial threshold and optimal initial weight of the BP neural network;
[0011] S3: Perform data preprocessing on historical network data, normalize the data to obtain network data to construct a training sample set, use the training sample set to train the BP neural network containing the optimal initial threshold and the optimal initial weight, evaluate the BP neural network by accuracy and recall, repeat iterations until the accuracy and recall are greater than the set threshold D1 to obtain a network intrusion detection model, thereby obtaining the optimal network intrusion detection model;
[0012] S4: The collected real-time network data is preprocessed to obtain test data, which is then input into a pre-trained network intrusion detection model to obtain network intrusion detection results.
[0013] Furthermore, the number of nodes in the input layer of the BP neural network in S1 is set to 45; the number of nodes in the hidden layer of the BP neural network is set to 100; and the number of nodes in the output layer of the BP neural network is set to 1.
[0014] Furthermore, the original threshold and original weight of the BP neural network in S2 are used as the initial population position of the chimpanzee optimization algorithm to optimize, and the method for obtaining the optimal initial threshold and optimal initial weight of the BP neural network includes:
[0015] The original weights of the BP neural network are used as the initial population positions of the improved chimpanzee optimization algorithm, and the chimpanzee optimization algorithm is optimized using piecewise mapping and adaptive factors.
[0016] Each chimpanzee population includes attackers, obstructors, pursuers and drivers. The attacker is the optimal solution in the population, and the others are suboptimal solutions. The adaptive factor is used to update their positions. The updated optimal solution position is designed as the update rule. The accuracy of the BP neural network is used as the fitness value to optimize the initial position, and the optimal initial threshold and optimal initial weight of the BP neural network are obtained.
[0017] Logistic mapping is used to initialize the chimpanzee population, and the formula is as follows:
[0018] Z k+1 =μZ k (1-Z k )
[0019] in,
[0020] Piecewise mapping is used to generate the m factor to strengthen the social motivation of the chimpanzee group and avoid falling into the local optimum. The mathematical model is as follows:
[0021]
[0022] Among them, P∈(0,1) is the control parameter; X k ∈(0,1);
[0023] Since other chimpanzees in the chimpanzee group update their positions according to the current positions of attackers, obstructors, pursuers and drivers, the standard chimpanzee algorithm is prone to fall into local optimality, so an adaptive factor is introduced to update the position; its formula is as follows:
[0024]
[0025] f h =f a +f b +f c +f d
[0026] In the formula, f a 、f b 、f c 、f d They are the current suitability of attackers, obstructors, pursuers and drivers respectively.
[0027] Furthermore, the method for obtaining historical network data in S3 to construct a training sample set includes:
[0028] Acquire historical network data; perform normalization processing on the historical network data to obtain training samples, and construct each training sample into a training sample set;
[0029] The BP neural network including the optimal initial threshold and the optimal initial weight is trained by using the training sample set, the BP neural network is evaluated by the accuracy and recall rate, and the network intrusion detection model is obtained by repeated iteration until the recall rate is greater than the set threshold D1. The method includes the following steps:
[0030] Ⅰ: Input the training samples into the BP neural network, transfer the training samples from the input layer to the output layer through forward propagation, and the output layer outputs the detection results; calculate the detection error based on the detection results of the training samples and the corresponding expected results; back propagate the BP neural network according to the detection error to update the weights and biases, and repeat the iteration until the set threshold D2 is reached to output the trained BP neural network;
[0031] Ⅱ: Use the training sample subset to test the trained BP neural network, evaluate the BP neural network through accuracy and recall rate, and output the BP neural network with a recall rate greater than the set threshold D1 as the network intrusion detection model; otherwise, jump to step Ⅰ.
[0032] Furthermore, the specific process of S4 includes the following contents: the method of transferring the training sample from the input layer to the output layer through forward propagation, and the output layer outputting the detection result includes:
[0033] z (1) =W (1) ·a (1.1) +b (1)
[0034] a (1) =σ(z (1) )
[0035] In the formula, a (1.1) is the output result of the 1.1 layer of the BP neural network, a (1) is the output result of the first layer, W (1) is the first layer weight matrix, b (1) is the first layer bias vector, σ(·) is the activation function;
[0036] The first layer of the BP neural network is the input layer, the second layer is the hidden layer, and the third layer is the output layer. The output result of the output layer is used as the detection result of the BP neural network.
[0037] Methods for calculating detection errors based on detection results of training samples and corresponding expected results include:
[0038]
[0039] Where, d j is the expected result of BP neural network for the jth sample detection, v j is the detection result of the BP neural network on the jth sample, J is the number of neurons in the output layer, and j is the sequence number of the neurons in the output layer;
[0040] The forward propagation of the working signal adjusts the weight ω between the hidden layer and the output layer ij and threshold θ i ; The error signal back propagates to adjust the weight ω between the input layer and the hidden layer mi and threshold b i , the weights and threshold corrections are:
[0041] Δω ij =μe j g′(u j )v i ,Δθ i =μδ i
[0042] Δω mi =μδ i v m ,Δb i =μδ i
[0043] in, μ is the neural network learning rate;
[0044] The method of back-propagating the BP neural network to update weights and biases according to the detection error includes:
[0045] Calculate the gradient of layer 1.1 in the BP network, the expression is:
[0046]
[0047]
[0048]
[0049] σ′(z (1) )=σ(z (1) )·(1-σ(z (1) ))
[0050] Where, e represents the detection error of BP neural network; σ(·) is the activation function; δ(m) represents the gradient of the 1.1th layer in BP neural network; (·) Τ Represented as the transpose of a matrix;
[0051] The error and gradient of each layer in the BP neural network are calculated layer by layer through back propagation to update the weights and bias of the BP neural network.
[0052] (III) Beneficial effects
[0053] Compared with the prior art, the present invention provides a BP neural network intrusion detection method based on an improved chimpanzee optimization algorithm, which has the following beneficial effects:
[0054] The present invention uses the original threshold and original weight of the BP neural network as the initial population position of the improved chimpanzee optimization algorithm to optimize, obtains the optimal initial threshold and optimal initial weight of the BP neural network, uses a training sample set to train the BP neural network containing the optimal initial threshold and the optimal initial weight, evaluates the BP neural network through accuracy and recall, repeats iteration until the recall rate is greater than a set threshold D1 to obtain a network intrusion detection model, and other processes, which can improve the accuracy of network intrusion detection and reduce the missed alarm rate and false alarm rate of the network intrusion detection model. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 is a flow chart of the method of the present invention;
[0056] Figure 2 It is the principle diagram of the BP neural network of the present invention. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] Example
[0059] like Figure 1 and Figure 2 As shown, an embodiment of the present invention proposes a BP neural network intrusion detection method based on an improved chimpanzee optimization algorithm, comprising the following steps:
[0060] S1: Construct a BP neural network and determine the number of nodes in the input layer, hidden layer, and output layer of the BP neural network;
[0061] S2: The original threshold and original weight of the BP neural network are used as the initial population position of the chimpanzee optimization algorithm to find the optimal initial threshold and optimal initial weight of the BP neural network;
[0062] S3: Perform data preprocessing on historical network data, normalize the data to obtain network data to construct a training sample set, use the training sample set to train the BP neural network containing the optimal initial threshold and the optimal initial weight, evaluate the BP neural network by accuracy and recall, repeat iterations until the accuracy and recall are greater than the set threshold D1 to obtain a network intrusion detection model, thereby obtaining the optimal network intrusion detection model;
[0063] S4: The collected real-time network data is preprocessed to obtain test data, which is then input into a pre-trained network intrusion detection model to obtain network intrusion detection results.
[0064] In this embodiment, the number of nodes in the input layer of the BP neural network in S1 is set to 45; the number of nodes in the hidden layer of the BP neural network is set to 100; and the number of nodes in the output layer of the BP neural network is set to 1.
[0065] In this embodiment, the original threshold and original weight of the BP neural network in S2 are used as the initial population position of the chimpanzee optimization algorithm to search for the optimal initial threshold and optimal initial weight of the BP neural network. The method includes:
[0066] The original weights of the BP neural network are used as the initial population positions of the improved chimpanzee optimization algorithm, and the chimpanzee optimization algorithm is optimized using piecewise mapping and adaptive factors.
[0067] Each chimpanzee population includes attackers, obstructors, pursuers and drivers. The attacker is the optimal solution in the population, and the others are suboptimal solutions. The adaptive factor is used to update their positions. The updated optimal solution position is designed as the update rule. The accuracy of the BP neural network is used as the fitness value to optimize the initial position, and the optimal initial threshold and optimal initial weight of the BP neural network are obtained.
[0068] Logistic mapping is used to initialize the chimpanzee population, and the formula is as follows:
[0069] Z k+1 =μZ k (1-Z k )
[0070] in,
[0071] Piecewise mapping is used to generate the m factor to strengthen the social motivation of the chimpanzee group and avoid falling into the local optimum. The mathematical model is as follows:
[0072]
[0073] Among them, P∈(0,1) is the control parameter; X k ∈(0,1);
[0074] Since other chimpanzees in the chimpanzee group update their positions according to the current positions of attackers, obstructors, pursuers and drivers, the standard chimpanzee algorithm is prone to fall into local optimality, so an adaptive factor is introduced to update the position; its formula is as follows:
[0075]
[0076] f h =f a +f b +f c +f d
[0077] In the formula, f a 、f b 、f c 、f d They are the current suitability of attackers, obstructors, pursuers and drivers respectively.
[0078] In this embodiment, the method of obtaining historical network data in S3 to construct a training sample set includes:
[0079] Acquire historical network data; perform normalization processing on the historical network data to obtain training samples, and construct each training sample into a training sample set;
[0080] The BP neural network including the optimal initial threshold and the optimal initial weight is trained by using the training sample set, the BP neural network is evaluated by the accuracy and recall rate, and the network intrusion detection model is obtained by repeated iteration until the recall rate is greater than the set threshold D1. The method includes the following steps:
[0081] Ⅰ: Input the training samples into the BP neural network, transfer the training samples from the input layer to the output layer through forward propagation, and the output layer outputs the detection results; calculate the detection error based on the detection results of the training samples and the corresponding expected results; back propagate the BP neural network according to the detection error to update the weights and biases, and repeat the iteration until the set threshold D2 is reached to output the trained BP neural network;
[0082] Ⅱ: Use the training sample subset to test the trained BP neural network, evaluate the BP neural network through accuracy and recall rate, and output the BP neural network with a recall rate greater than the set threshold D1 as the network intrusion detection model; otherwise, jump to step Ⅰ.
[0083] In this embodiment, the specific process of S4 includes the following: the method of transferring the training sample from the input layer to the output layer through forward propagation, and the output layer outputting the detection result includes:
[0084] z (1) =W (1) ·a (1.1) +b (1)
[0085] a (1) =σ(z (1) )
[0086] In the formula, a (1.1) is the output result of the 1.1 layer of the BP neural network, a (1) is the output result of the first layer, W (1) is the first layer weight matrix, b (1) is the first layer bias vector, σ(·) is the activation function;
[0087] The first layer of the BP neural network is the input layer, the second layer is the hidden layer, and the third layer is the output layer. The output result of the output layer is used as the detection result of the BP neural network.
[0088] Methods for calculating detection errors based on detection results of training samples and corresponding expected results include:
[0089]
[0090] Where, d j is the expected result of BP neural network for the jth sample detection, v jis the detection result of the BP neural network on the jth sample, J is the number of neurons in the output layer, and j is the sequence number of the neurons in the output layer;
[0091] The forward propagation of the working signal adjusts the weight ω between the hidden layer and the output layer ij and threshold θ i ; The error signal back propagates to adjust the weight ω between the input layer and the hidden layer mi and threshold b i , the weights and threshold corrections are:
[0092] Δω ij =μe j g′(u j )v i ,Δθ i =μδ i
[0093] Δω mi =μδ i v m ,Δb i =μδ i
[0094] in, μ is the neural network learning rate;
[0095] The method of back-propagating the BP neural network to update weights and biases according to the detection error includes:
[0096] Calculate the gradient of layer 1.1 in the BP network, the expression is:
[0097]
[0098]
[0099]
[0100] σ′(z (1) )=σ(z (1) )·(1-σ(z (1) ))
[0101] Where, e represents the detection error of BP neural network; σ(·) is the activation function; δ (m) Represented as the gradient of layer 1.1 in the BP neural network; (·) Τ Represented as the transpose of a matrix;
[0102] The error and gradient of each layer in the BP neural network are calculated layer by layer through back propagation to update the weights and bias of the BP neural network.
[0103] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A BP neural network intrusion detection method based on an improved chimpanzee optimization algorithm, characterized in that: The following steps are involved: S1: Construct a BP neural network and determine the number of nodes in the input layer, hidden layer, and output layer of the BP neural network; S2: The original threshold and original weight of the BP neural network are used as the initial population position of the chimpanzee optimization algorithm to find the optimal initial threshold and optimal initial weight of the BP neural network; S3: Perform data preprocessing on historical network data, normalize the data to obtain network data to construct a training sample set, use the training sample set to train the BP neural network containing the optimal initial threshold and the optimal initial weight, evaluate the BP neural network by accuracy and recall, repeat iterations until the accuracy and recall are greater than the set threshold D1 to obtain a network intrusion detection model, thereby obtaining the optimal network intrusion detection model; S4: The collected real-time network data is preprocessed to obtain test data, which is then input into a pre-trained network intrusion detection model to obtain network intrusion detection results.
2. The BP neural network intrusion detection method based on the improved chimpanzee optimization algorithm according to claim 1 is characterized in that: The number of nodes in the input layer of the BP neural network in S1 is set to 45; the number of nodes in the hidden layer of the BP neural network is set to 100; and the number of nodes in the output layer of the BP neural network is set to 1.
3. A BP neural network intrusion detection method based on an improved chimpanzee optimization algorithm according to claim 2, characterized in that: The original threshold and original weight of the BP neural network in S2 are used as the initial population position of the chimpanzee optimization algorithm to optimize, and the method for obtaining the optimal initial threshold and optimal initial weight of the BP neural network includes: The original weights of the BP neural network are used as the initial population positions of the improved chimpanzee optimization algorithm, and the chimpanzee optimization algorithm is optimized using piecewise mapping and adaptive factors. Each chimpanzee population includes attackers, obstructors, pursuers and drivers. The attacker is the optimal solution in the population, and the others are suboptimal solutions. The adaptive factor is used to update their positions. The updated optimal solution position is designed as the update rule. The accuracy of the BP neural network is used as the fitness value to optimize the initial position, and the optimal initial threshold and optimal initial weight of the BP neural network are obtained. Logistic mapping is used to initialize the chimpanzee population, and the formula is as follows: Z k+1 =μZ k (1-Z k ) in, μ∈[0,4]; Piecewise mapping is used to generate the m factor to strengthen the social motivation of the chimpanzee group and avoid falling into the local optimum. The mathematical model is as follows: Among them, P∈(0,1) is the control parameter; X k ∈(0,1); Since other chimpanzees in the chimpanzee group update their positions according to the current positions of attackers, obstructors, pursuers and drivers, the standard chimpanzee algorithm is prone to fall into local optimality, so an adaptive factor is introduced to update the position; its formula is as follows: f h =f a +f b +f c +f d In the formula, f a 、f b 、f c 、f d They are the current suitability of attackers, obstructors, pursuers and drivers respectively.
4. A BP neural network intrusion detection method based on an improved chimpanzee optimization algorithm according to claim 3, characterized in that: The method for obtaining historical network data in S3 to construct a training sample set includes: Acquire historical network data; perform normalization processing on the historical network data to obtain training samples, and construct each training sample into a training sample set; The BP neural network including the optimal initial threshold and the optimal initial weight is trained by using the training sample set, the BP neural network is evaluated by the accuracy and recall rate, and the network intrusion detection model is obtained by repeated iteration until the recall rate is greater than the set threshold D1. The method includes the following steps: Ⅰ: Input the training samples into the BP neural network, transfer the training samples from the input layer to the output layer through forward propagation, and the output layer outputs the detection results; calculate the detection error based on the detection results of the training samples and the corresponding expected results; back propagate the BP neural network according to the detection error to update the weights and biases, and repeat the iteration until the set threshold D2 is reached to output the trained BP neural network; Ⅱ: Use the training sample subset to test the trained BP neural network, evaluate the BP neural network through accuracy and recall rate, and output the BP neural network with a recall rate greater than the set threshold D1 as the network intrusion detection model; otherwise, jump to step Ⅰ.
5. A BP neural network intrusion detection method based on an improved chimpanzee optimization algorithm according to claim 4, characterized in that: The specific process of S4 includes the following: the method of transferring the training sample from the input layer to the output layer through forward propagation, and the output layer outputting the detection result includes: z (1) =W (1) ·a (1.1) +b (1) a (1) =σ(z (1) ) In the formula, a (1.1) is the output result of the 1.1 layer of the BP neural network, a (1) is the output result of the first layer, W (1) is the first layer weight matrix, b (1) is the first layer bias vector, σ(·) is the activation function; The first layer of the BP neural network is the input layer, the second layer is the hidden layer, and the third layer is the output layer. The output result of the output layer is used as the detection result of the BP neural network. Methods for calculating detection errors based on detection results of training samples and corresponding expected results include: Where, d j is the expected result of BP neural network for the jth sample detection, v j is the detection result of the BP neural network on the jth sample, J is the number of neurons in the output layer, and j is the sequence number of the neurons in the output layer; The forward propagation of the working signal adjusts the weight ω between the hidden layer and the output layer ij and threshold θ i ; The error signal back propagates to adjust the weight ω between the input layer and the hidden layer mi and threshold b i , the weights and threshold corrections are: Give ij =μe j g′(u j )v i ,Dth i =md i Give mi =md i v m ,Δb i =md i in, μ is the neural network learning rate; The method of back-propagating the BP neural network to update weights and biases according to the detection error includes: Calculate the gradient of layer 1.1 in the BP network, the expression is: σ′(z (1) )=σ(z (1) )·(1-σ(z (1) )) Where, e represents the detection error of BP neural network; σ(·) is the activation function; δ (m) Represented as the gradient of layer 1.1 in the BP neural network; (·) Τ Represented as the transpose of a matrix; The error and gradient of each layer in the BP neural network are calculated layer by layer through back propagation to update the weights and bias of the BP neural network.
