A model migration-based intelligent pumped storage power station online intrusion detection method
Patent Information
- Application Number
- CN202211282911.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-19
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2042-10-19
AI Technical Summary
[0006]本发明的目的在于,针对现有相关研究基于目标域数据均已存在的假设从而使用离线学习模型造成训练效率低的问题,提供一种基于模型迁移的智能抽水蓄能电站在线入侵检测方法
[0081] This invention provides an online intrusion detection method for intelligent pumped-storage power stations based on model transfer learning. By combining transfer learning with intrusion detection mechanisms, it effectively solves the problem of insufficient data on novel attacks. Furthermore, by combining transfer learning with online learning to construct an online intrusion detection method based on transfer learning, it significantly improves the model's training efficiency and the detection rate of novel attacks, overcoming both the low training efficiency and data scarcity issues of existing related technologies. In addition, the method provided by this invention has a shorter training time and is more suitable for intrusion detection systems for intelligent pumped-storage power stations with high real-time requirements.
Smart Images

Figure CN116800453B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intrusion detection systems, and particularly relates to an online intrusion detection method for intelligent pumped storage power stations based on model transfer. Background Technology
[0002] Intelligent pumped storage power stations store electrical charge by pumping water during off-peak hours and releasing it as a power source during peak hours. This helps with grid frequency regulation and peak shaving, as well as black start, eliminating the impact of grid frequency deviation and voltage fluctuations caused by large-scale grid connection of new energy sources. It also effectively reduces the number of deep peak shaving start-ups and shutdowns of thermal power units, thereby improving the grid's energy utilization rate.
[0003] However, as an important peak-shaving and valley-filling node in the power grid, the industrial control system of the intelligent pumped storage power station based on 5G technology is facing increasing information security problems. While it uses ultra-high bandwidth and ultra-large-scale connection to realize holographic information collection, remote control and emergency command tasks, threats such as viruses and Trojans are also spreading.
[0004] Therefore, intrusion detection systems are crucial for ensuring the security of smart grids. Intrusion detection systems utilize machine learning or deep learning to build models on massive amounts of data to identify abnormal behavior. However, over time, new types of attacks constantly emerge in the industrial control systems of smart pumped storage power stations, and the amount of data on these new attacks is usually very small. This makes it difficult for machine learning methods based on large amounts of data to learn effectively, leading to a decline in detection performance.
[0005] To address this issue, related research has proposed intrusion detection systems based on transfer learning, effectively solving the problem of data scarcity. However, current research on intrusion detection systems based on transfer learning assumes that all target domain data already exists and uses offline learning models to train on all data. This results in low training efficiency for the designed intrusion detection systems, failing to meet the dynamic characteristics of industrial control system networks. Summary of the Invention
[0006] The purpose of this invention is to address the problem of low training efficiency caused by the use of offline learning models based on the assumption that the target domain data already exists in existing related studies, and to provide an online intrusion detection method for intelligent pumped storage power stations based on model transfer.
[0007] Therefore, the above-mentioned objective of the present invention is achieved through the following technical solution:
[0008] A model transfer-based online intrusion detection method for intelligent pumped storage power stations, characterized by the following steps:
[0009] S1: The NSL-KDD dataset was used as the experimental data, and the data was preprocessed.
[0010] S2: Construct an offline module for intrusion detection source domain and train the offline module for intrusion detection source domain using the data preprocessed in step S1;
[0011] S3: Construct an online intrusion detection module for the target domain, and use the offline intrusion detection module for the source domain converged in step S2 to initialize the online intrusion detection module for the target domain using transfer learning. When new data arrives, use online learning methods to update it in real time, thereby realizing the detection of new attacks and improving training efficiency.
[0012] While adopting the above technical solutions, the present invention may also adopt or combine the following technical solutions:
[0013] As a preferred embodiment of the present invention, step S1 specifically includes the following steps:
[0014] S101: Selection of dataset;
[0015] The NSL-KDD dataset contains four attack types: DoS (Denial of Service attack), Probe (surveillance and other probing activities), U2R (unauthorized access by ordinary users to superuser privileges), R2L (unauthorized access from remote machines), and Normal (normal data).
[0016] The NSL-KDD dataset contains the training set KDDTrain+ and the test dataset KDDTest+. KDDTest+ contains 17 new attack data belonging to the four major attack categories mentioned above, compared to KDDTrain+. Therefore, it is used as the experimental data.
[0017] S102: Data preprocessing;
[0018] This invention does not focus on the class imbalance problem between the source and target domains. Therefore, some data from R2L and U2R in KDDTest+ are transferred to KDDTrain+ to make the class proportions in the two datasets roughly the same. The adjusted KDDTrain+ is used as the source domain dataset and KDDTest+ is used as the target domain dataset. One-hot encoding, data normalization, and two-dimensionalization are performed on the data in the target and source domains to facilitate subsequent feature extraction.
[0019] As a preferred embodiment of the present invention, step S2 specifically includes the following steps:
[0020] S201: Construct a source domain feature extractor;
[0021] A feature extraction model is built on the source domain data using the classic LeNet-5 convolutional neural network structure to extract general underlying knowledge; the network structure of LeNet-5 except for the output layer is used as the feature extractor, and the data preprocessed in step S1 is used as the input of the feature extractor, and the output is the extracted feature vector.
[0022] S202: Construct the source domain classifier;
[0023] ELM is a single-hidden-layer feedforward neural network consisting of an input layer, hidden layers, and an output layer. The weights and biases between the input and hidden layers are randomly selected. After determining the number of hidden nodes, the weights between the hidden and output layers can be calculated using the least squares method. It has fast training speed, good generalization performance, and can be extended to the online learning method OS-ELM for incremental learning on data. Therefore, ELM is used as the source domain classifier. The working principle of the ELM classifier is as follows:
[0024] Randomly select the weights 'a' and biases 'b' between the input and hidden nodes of the ELM classifier to determine the size of the hidden nodes. The sigmoid function is chosen as the activation function h for the hidden nodes, as shown in the following formula, where x is the input data;
[0025]
[0026] The hidden layer output matrix H, the output weight matrix β between the hidden layer and the output layer, and the label vector matrix T of ELM are respectively represented as follows:
[0027]
[0028] Wherein, the total number of input categories is m, and the input features are N arbitrary samples (x) with dimension n. i , t i Input sample x i = (x1, x2, ..., x N )∈R n Sample label t i = (t1, t2, ..., t N )∈R m ;
[0029] The output function of the ELM classifier is defined as:
[0030] f(x) = arg max H(x)β
[0031] Training the source domain classifier can be viewed as extracting knowledge from the source domain data, using the feature vector extracted in step S201 as the input to the ELM classifier; let the source domain dataset contain N... sWith training samples, the ELM training process is equivalent to optimizing the output weight matrix β of the source domain classifier. s and the square of the training error for each source domain sample sum:
[0032]
[0033]
[0034] Where C is the regularization parameter, (x i , t i ), i = 1, 2, ..., N s For N s Given a source domain sample, the output weight matrix of the source domain classifier can be obtained using the Lagrange multiplier method:
[0035]
[0036] Where, β s H is the output weight matrix of the source domain classifier, and H is the hidden layer output matrix of the source domain classifier. T Let T be the transpose of H. s This is the label vector matrix of the source domain data.
[0037] As a preferred embodiment of the present invention, step S3 specifically includes the following steps:
[0038] S301: Construct an online intrusion detection module for the target domain using the model transfer method;
[0039] The source domain feature extractor of the intrusion detection source domain offline module constructed in step S2 is transferred to the online module to construct the online module feature extractor. Furthermore, the classifier trained in the source domain of the intrusion detection source domain offline module is transferred to construct the initialization model of TOS-ELM. To transfer the knowledge learned from the source domain to the target domain, a term minimizing the target domain classifier parameter β is added. t Source domain classifier parameter β s The Euclidean distance between them is optimized as follows:
[0040]
[0041]
[0042] Where μ is the penalty parameter and C is the regularization parameter. For existing target domain samples, β t Let β be the output weight matrix of the target domain classifier. s The output weight matrix of the source domain classifier. The training error for each target domain sample; the amount of training data used for initialization should be greater than or equal to the number of hidden nodes; depending on the similarity between the source and target domains, μ is not necessarily better the larger it is. When μ can more accurately describe the similarity between the two, the target domain classifier can learn an appropriate amount of source domain knowledge, thus achieving higher accuracy; otherwise, it will cause negative transfer, resulting in lower classification accuracy than without transfer.
[0043] The target domain weight matrix β is obtained using the Lagrange multiplier method. t :
[0044]
[0045] Where, β t H is the source domain output weight matrix, and H is the hidden layer output matrix of the target domain classifier. T Let T be the transpose of H. t The label vector matrix of the target domain data;
[0046] S302: Online update of the target domain online intrusion detection module;
[0047] In practice, new data often arrives online; therefore, the model needs to be trained and updated online for timely detection. In the k-th round, For the newly arrived target domain data, due to N t and N k Given target domain data, the training error of the model on both the already acquired target domain data and the newly arrived target domain data should be as small as possible. Therefore, the optimization objective becomes:
[0048]
[0049]
[0050]
[0051] Based on the target domain weight matrix in S301, we can obtain:
[0052]
[0053] set up
[0054] in,
[0055] At this point, in the formula for the target domain weight matrix:
[0056]
[0057] Among them, H tH is the hidden layer matrix of the target domain data that has already been obtained. k For the hidden layer matrix of the newly arrived target domain data, T t For the labels of the target domain data that have already been obtained, T k Substituting the labels of the newly arrived target domain data into the target domain weight matrix formula yields:
[0058]
[0059] make:
[0060]
[0061] P k Use P t express:
[0062]
[0063] According to the inverse Woodbury matrix lemma, P k Use P t The recurrence relation is obtained as follows:
[0064]
[0065] Therefore, we can obtain β k Use β t The recursive form of:
[0066]
[0067] Where, β t β s T k and H k All are known matrices, P k You can be in P t Based on this, it is recursively derived that, when new data arrives, the output weight matrix β of the TOS-ELM classifier... k It can be obtained recursively from the old model, without the need to retrain using previously obtained data, thus the training speed is faster.
[0068] S303: Construct an ensemble classifier;
[0069] Considering the unstable performance of a single classifier, an ensemble learning method is used. Since different classifiers have different preferences, even if one classifier makes a wrong prediction, other classifiers can correct it. During initialization, L TOS-ELM base models are constructed according to different penalty parameters μ, and each base model is assigned different weights based on its performance on new data. The classification performance of the ensemble system on new samples may decrease. Therefore, when the accuracy of the ensemble system is not up to standard, a new model is constructed to replace the model with the lowest weight to alleviate this problem.
[0070] In classification problems, the main criterion for evaluating model performance is classification accuracy. In the field of intrusion detection, attack samples are typically defined as positive classes, and normal samples as negative classes. The following four cases are defined: TP (True Instance), representing the number of correctly classified attack samples; TN (True Negative Instance), representing the number of correctly classified normal samples; FN (False Negative Instance), representing the number of normal samples misclassified as attack samples; and FP (False Positive Instance), representing the number of attack samples misclassified as normal samples. Accuracy is then expressed as:
[0071]
[0072] When new data arrives in the kth round, the cumulative accuracy is defined.
[0073]
[0074] Among them, item n The current iteration update number for the nth base classifier is based on the accuracy of the nth base classifier on the kth round of new data. and previous items n The cumulative accuracy score of the round Calculated
[0075] According to each model The following formula updates the model weights.
[0076]
[0077] The initial value is 1 / L; when the cumulative Acc score of the nth model... When the value is greater than the average, its weight increases; the higher the accuracy of the base model on new data samples, the higher the weight; the value of the penalty parameter μ will result in a higher ensemble weight for a classifier that more accurately describes the similarity between the source and target domains; based on the weights combined with the base model, and according to the soft voting method, the output of the ensemble model is:
[0078]
[0079] Among them, S n (x) represents the predicted probability of sample x belonging to class m by the nth base model. After weighted summation of the outputs of L classifiers, the class m with the highest probability is taken as the final output class.
[0080] As a preferred technical solution of the present invention: in step S3, the accuracy of the system in detecting abnormal behavior can be further improved by using ensemble learning of multiple classifiers.
[0081] This invention provides an online intrusion detection method for intelligent pumped-storage power stations based on model transfer learning. By combining transfer learning with intrusion detection mechanisms, it effectively solves the problem of insufficient data on novel attacks. Furthermore, by combining transfer learning with online learning to construct an online intrusion detection method based on transfer learning, it significantly improves the model's training efficiency and the detection rate of novel attacks, overcoming both the low training efficiency and data scarcity issues of existing related technologies. In addition, the method provided by this invention has a shorter training time and is more suitable for intrusion detection systems for intelligent pumped-storage power stations with high real-time requirements. Attached Figure Description
[0082] Figure 1 This is a framework diagram of the online intrusion detection method for intelligent pumped storage power stations based on model transfer provided by the present invention.
[0083] Figure 2 This is a diagram of the LeNet-5 network architecture.
[0084] Figure 3 Data distribution diagrams for KDDTrain+ and KDDTest+.
[0085] Figure 4 The graph shows the performance of TOS-ELM at different μ values.
[0086] Figure 5 A comparison chart showing the classification accuracy of the algorithms.
[0087] Figure 6 A comparison chart of the false positive rates of the classification algorithms.
[0088] Figure 7 This is a comparison chart of the detection rates of the algorithms.
[0089] Figure 8 This is a comparison chart of online training times for the algorithms. Detailed Implementation
[0090] The present invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
[0091] like Figure 1As shown, an online intrusion detection method for intelligent pumped storage power stations based on model transfer (CNN-TOSELM) specifically includes the following steps:
[0092] S1: The NSL-KDD dataset was used as the experimental data, and the data was preprocessed.
[0093] S2: Construct an offline module for intrusion detection source domain and train the offline module for intrusion detection source domain using the data preprocessed in step S1;
[0094] S3: Construct an online intrusion detection module for the target domain, and use the offline intrusion detection module for the source domain converged in step S2 to initialize the online intrusion detection module for the target domain using transfer learning. When new data arrives, use online learning methods to update it in real time, thereby realizing the detection of new attacks and improving training efficiency.
[0095] Furthermore, the accuracy of the system in detecting abnormal behavior can be further improved by using ensemble learning of multiple classifiers.
[0096] Step S1 is as follows:
[0097] S101: Dataset Selection. The NSL-KDD dataset contains four attack types: DoS (Denial of Service attack), Probe (surveillance and other probing activities), U2R (unauthorized access by ordinary users to superuser privileges), R2L (unauthorized access from remote machines), and Normal (normal data). Furthermore, the NSL-KDD dataset includes the training set KDDTrain+ and the test dataset KDDTest+. KDDTest+ contains 17 new attack data belonging to the aforementioned four attack categories compared to KDDTrain+, therefore it was used as the experimental data.
[0098] S102: Data Preprocessing. Since this invention does not focus on the class imbalance problem between the source and target domains, some data from R2L and U2R in KDDTest+ are transferred to KDDTrain+ to make the class proportions in the two datasets approximately equal. Figure 3 The diagram shows the data distribution of the source and target domains. The adjusted KDDTrain+ was used as the source dataset, and KDDTest+ as the target dataset. One-hot encoding, data normalization, and two-dimensionalization were performed on the data in both the source and target domains to facilitate subsequent feature extraction. The types and numbers of new attacks in each type of attack in the target domain after adjustment are shown in Table 1 below.
[0099] Table 1. New attack categories and quantities in the adjusted target domain
[0100]
[0101] Step S2 is as follows:
[0102] S201: Construct the source domain feature extractor in the intrusion detection source domain offline module. For example... Figure 2 As shown, this invention utilizes the classic LeNet-5 convolutional neural network structure to establish a feature extraction model on source domain data, extracting general underlying knowledge. This invention uses the LeNet-5 network structure excluding the output layer as the feature extractor and the preprocessed data from step 1 as the input to the feature extractor, with the output being the extracted feature vector.
[0103] S202: Constructing the source domain classifier in the offline module for intrusion detection. ELM is a single-hidden-layer feedforward neural network consisting of an input layer, hidden layers, and an output layer. The weights and biases between the input and hidden layers are randomly selected. After determining the number of hidden nodes, the weights between the hidden and output layers can be calculated using the least squares method. It has fast training speed, good generalization performance, and can be extended to the online learning method OS-ELM for incremental learning on data. Therefore, this invention uses ELM as the source domain classifier. The working principle of the ELM classifier is as follows:
[0104] Randomly select the weights 'a' and biases 'b' between the input and hidden nodes of the ELM classifier to determine the size of the hidden nodes. The sigmoid function is chosen as the activation function for the hidden nodes, as shown in the following equation, where x is the input data.
[0105]
[0106] The hidden layer output matrix H, the output weight matrix β between the hidden layer and the output layer, and the label vector matrix T of ELM are respectively represented as follows:
[0107]
[0108] Wherein, the total number of input categories is m, and the input features are N arbitrary samples (x) with dimension n. i , t i Input sample x i = (x1, x2, ..., x N )∈R n Sample label t i = (t1, t2, ..., t N )∈R m .
[0109] The output function of the ELM classifier is defined as:
[0110] f(x) = arg max H(x)β
[0111] Training the source domain classifier can be viewed as extracting knowledge from the source domain data, using the feature vector extracted in step 201 as input to the ELM classifier. Let the source domain dataset contain N... s With training samples, the ELM training process is equivalent to optimizing the output weight matrix β. s and the square of the training error for each sample sum:
[0112]
[0113]
[0114] Where C is the regularization parameter, (x i , t i ), i = 1, 2, ..., N s For N s Given a source domain sample, the output weight matrix of the source domain classifier can be obtained using the Lagrange multiplier method:
[0115]
[0116] Step S3 is as follows:
[0117] S301: Model Transfer; The source domain feature extractor constructed in step S2 is transferred to the online module to complete the initialization of the online module feature extractor. Furthermore, the source domain classifier is transferred to construct the initialization model of TOS-ELM. To transfer the knowledge learned from the source domain to the target domain, a term minimizing the target domain classifier parameter β is added. t Source domain classifier parameter β s The Euclidean distance between them is optimized as follows:
[0118]
[0119]
[0120] Where μ is the penalty parameter and C is the regularization parameter. The initial training data should be greater than or equal to the number of hidden nodes. Depending on the similarity between the source and target domains, μ is not necessarily better the larger it is. When μ can more accurately describe the similarity between the two, the target domain classifier can learn an appropriate level of source domain knowledge, thus achieving higher accuracy. Conversely, a smaller μ will cause negative transfer, resulting in lower classification accuracy than without transfer. Figure 4 The graphs show the performance of TOS-ELM at different μ values. The left graph represents the accuracy, and the right graph represents the false alarm rate.
[0121] The target domain weight matrix β is obtained using the Lagrange multiplier method. t :
[0122]
[0123] S302: Online Update. In practice, new data often arrives online, therefore, online training and updates of the model are necessary for timely detection. In the k-th round, For the newly arrived target domain data, due to N t and N k Given target domain data, the training error of the model on both the already acquired target domain data and the newly arrived target domain data should be as small as possible. Therefore, the optimization objective becomes:
[0124]
[0125]
[0126]
[0127] Based on the target domain weight matrix in step S301, we can obtain:
[0128]
[0129] set up in
[0130] At this point, in the formula for the target domain weight matrix:
[0131]
[0132] Among them, H t H is the hidden layer matrix of the target domain data that has already been obtained. k For the hidden layer matrix of the newly arrived target domain data, T t For the labels of the target domain data that have already been obtained, T k Substituting the labels of the newly arrived target domain data into the weight matrix formula yields:
[0133]
[0134] make:
[0135]
[0136] P k Use P t express:
[0137]
[0138] According to the inverse Woodbury matrix lemma, P k Use P tThe recurrence relation is obtained as follows:
[0139]
[0140] Therefore, β can be obtained. k Use β t The recursive form of:
[0141]
[0142] In the above formula, β t β s T k and H k All are known matrices, P k You can be in P t Based on this, it is recursively derived that, when new data arrives, the output weight matrix β of the TOS-ELM classifier... k It can be obtained recursively from the old model, without the need for retraining using previously obtained data. Therefore, the training speed is relatively fast.
[0143] Step 303: Construct the ensemble classifier. Considering the unstable performance of a single classifier, an ensemble learning method is used. Since different classifiers have different preferences, even if one classifier makes a wrong prediction, the others can correct it. During initialization, L TOS-ELM base models are constructed based on different penalty parameters μ, and each base model is assigned different weights according to its performance on new data. The classification performance of the ensemble system on new samples may decrease; therefore, when the accuracy of the ensemble system is insufficient, a new model is constructed to replace the model with the lowest weight to alleviate this problem.
[0144] In classification problems, the primary criterion for evaluating model performance is classification accuracy. In intrusion detection, attack samples are typically defined as the positive class, and normal samples as the negative class. Four cases are defined: TP (True Instance), representing the number of correctly classified attack samples; TN (True Negative Instance), representing the number of correctly classified normal samples; FN (False Negative Instance), representing the number of normal samples misclassified as attack samples; and FP (False Positive Instance), representing the number of attack samples misclassified as normal samples. Accuracy is then expressed as:
[0145]
[0146] When new data arrives in the kth round, the cumulative accuracy is defined.
[0147]
[0148] Among items nThe current iteration update number for the nth base classifier is determined by the accuracy of the nth base classifier on the kth round of new data. And previous items n The cumulative accuracy score of the round Calculated According to each model Update the model weights according to the following formula.
[0149]
[0150] The initial value is 1 / L. When the cumulative Acc score of the nth model... When the value is greater than the average, its weight increases. The higher the accuracy of the base model on new data samples, the higher the weight. The value of the penalty parameter μ will result in a higher ensemble weight for a classifier that more accurately describes the similarity between the source and target domains. Based on the weighted base model, and according to the soft voting method, the output of the ensemble model is:
[0151]
[0152] Among them, S n (x) represents the predicted probability of sample x belonging to class m by the nth base model. After weighted summation of the outputs of L classifiers, the class m with the highest probability is taken as the final output class.
[0153] This invention selects three algorithms as comparison algorithms: the Tradaboost method based on sample transfer learning, the CNN-finetune method for model fine-tuning, and the CNN method for non-transfer learning.
[0154] Figure 5 This is a comparison of the five-class classification accuracy of this invention with three other methods. Figure 5 As shown, when the amount of data is small, the CNN-TOSELM method of this invention achieves higher accuracy due to the combination of the good feature extraction capabilities of pre-trained CNNs and the ability of TOS-ELM to utilize the knowledge of the source domain classifier model parameters. However, as the amount of data gradually increases, the accuracy of the CNN-TOSELM method gradually falls below that of Tradaboost, which learns from all the data, because it only learns from newly arriving data online.
[0155] Figure 6 This is a comparison of the false alarm rate of the present invention with that of three other methods in the five-class classification. Figure 6As shown, CNN-TOSELM has a lower average false positive rate compared to CNN-finetune and CNN methods. The main reasons are: first, during the transfer learning process, it extracts knowledge from a large amount of normal traffic data in the source domain; second, ensemble learning can combine the outputs of multiple classifiers. The Tradaboost method directly uses a large amount of normal data from the source domain for training, learning more features of normal traffic, thus resulting in a lower false positive rate.
[0156] Figure 7 The chart shows a comparison of the detection rates of the algorithms. When the amount of data is small, the detection rate of the method described in this invention is higher than that of the other three methods. Because the Tradaboost method directly utilizes both source and target data during training, with far more normal data than new attack data, its detection rate for attack data is relatively lower than that of the method described in this invention when the target domain data is limited. As the target domain data increases, the Tradaboost method learns from all data, thus its detection rate gradually surpasses that of the method described in this invention. However, overall, the average detection rate of the method described in this invention is higher.
[0157] Figure 8 This is a comparison chart of the training time of the present invention and the comparison algorithm. From Figure 8 As can be seen from the results, compared with other methods, this invention achieves better detection performance while having a shorter training time, making it more suitable for intrusion detection systems in intelligent pumped storage power stations with high real-time requirements.
[0158] The above specific embodiments are used to explain and illustrate the present invention, and are only preferred embodiments of the present invention, not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made to the present invention within the spirit and scope of the claims shall fall within the protection scope of the present invention.
Claims
1. A method for online intrusion detection in intelligent pumped storage power stations based on model transfer, characterized in that: The method includes the following steps: S1: The NSL-KDD dataset was used as the experimental data, and the data was preprocessed. S2: Construct an offline module for intrusion detection source domain and train the offline module for intrusion detection source domain using the data preprocessed in step S1; S3: Construct an online intrusion detection module for the target domain, and use the offline intrusion detection module for the source domain converged in step S2 to initialize the online intrusion detection module for the target domain using transfer learning. When new data arrives, use online learning methods to update in real time to detect new attacks and improve training efficiency. Step S2 specifically includes the following steps: S201: Construct the source domain feature extractor in the intrusion detection source domain offline module; A feature extraction model is built on the source domain data using the classic LeNet-5 convolutional neural network structure to extract general underlying knowledge; the network structure of LeNet-5 except for the output layer is used as the source domain feature extractor, and the data preprocessed in step S1 is used as the input of the source domain feature extractor, and the output is the extracted feature vector. S202: Construct the source domain classifier in the intrusion detection source domain offline module; ELM is a single-hidden-layer feedforward neural network consisting of an input layer, hidden layers, and an output layer. The weights and biases between the input and hidden layers are randomly selected. After determining the number of hidden nodes, the weights between the hidden and output layers are calculated using the least squares method. Furthermore, it is extended to the online learning method OS-ELM for incremental learning on the data. Therefore, ELM is used as the source domain classifier. The working principle of the ELM classifier is as follows: Randomly select the weights 'a' and biases 'b' between the input and hidden nodes of the ELM classifier to determine the size of the hidden nodes. We choose the sigmoid function as the activation function h for the hidden nodes, as shown in the following formula, where x is the input data; The hidden layer output matrix H, the output weight matrix β between the hidden layer and the output layer, and the label vector matrix T of ELM are respectively represented as follows: Where the total number of input categories is m, and the dimension of the input features is... n of N any sample (x i ,t i ) Input Sample x i =(x 1 , x 2 ,...,x N ) ∈ R n Sample Labels t i =(t 1 ,t 2 ,...,t N )∈R m ; The output function of the ELM classifier is defined as: Training the source domain classifier is considered as extracting knowledge from the source domain data, using the feature vector extracted in step S201 as the input to the ELM classifier; assuming the source domain dataset contains... With training samples, the ELM training process is equivalent to optimizing the output weight matrix of the source domain classifier by minimizing the output weight matrix of the source domain classifier. and the square of the training error for each source domain sample sum: Where C is the regularization parameter, (x i ,t i ) , i=1,2,..., for The output weight matrix of the source domain classifier can be obtained from the source domain samples using the Lagrange multiplier method. : in, H is the output weight matrix of the source domain classifier, and H is the hidden layer output matrix of the source domain classifier. T Let H be the transpose of H. The label vector matrix of the source domain data; Step S3 specifically includes the following steps: S301: Construct an online intrusion detection module for the target domain using the model transfer method; The source domain feature extractor of the intrusion detection source domain offline module constructed in step S2 is transferred to the online module to construct the feature extractor of the target domain online intrusion detection module. Furthermore, the source domain classifier of the intrusion detection source domain offline module is transferred to construct the initialization model of TOS-ELM. To transfer the knowledge learned from the source domain to the target domain, a term minimizing the target domain classifier parameters is added. β t Source domain classifier parameters β s The Euclidean distance between them is optimized as follows: Where μ is the penalty parameter and C is the regularization parameter. ,i=1,2,..., For existing target domain samples, The output weight matrix of the target domain classifier. The output weight matrix of the source domain classifier. The training error for each target domain sample; the amount of training data used for initialization should be greater than or equal to the number of hidden nodes; depending on the similarity between the source and target domains, μ is not necessarily better the larger it is. When μ more accurately describes the similarity between the two, the target domain classifier can learn an appropriate amount of source domain knowledge, thus achieving higher accuracy; otherwise, it will cause negative transfer, resulting in lower classification accuracy than without transfer. The target domain weight matrix is obtained using the Lagrange multiplier method. β t : in, H is the source domain output weight matrix, and H is the hidden layer output matrix of the target domain classifier. T Let H be the transpose of H. The label vector matrix of the target domain data; S302: Online update of the target domain online intrusion detection module; In practice, new data arrives online; therefore, the model needs to be trained and updated online for timely detection. k wheel, ,l=1,2,..., For the newly arrived target domain data, due to and Given target domain data, the training error of the model on both the already acquired target domain data and the newly arrived target domain data should be as small as possible. Therefore, the optimization objective becomes: Based on the target domain weight matrix in S301, we can obtain: set up in, ; At this point, in the formula for the target domain weight matrix: in, H t The hidden layer matrix of the target domain data that has already been obtained. H k The hidden layer matrix for the newly arrived target domain data. T t The labels for the target domain data that have already been obtained. T k Substituting the labels of the newly arrived target domain data into the target domain weight matrix formula yields: make: Will P k use P t express: According to the inverse lemma of the Woodbury matrix, P k use P t The recurrence relation is obtained as follows: Therefore, we can obtain β k use β t The recursive form of: in, β t , β s , T k and H k All are known matrices. P k exist P t It is obtained recursively based on this; S303: Construct an ensemble classifier; Considering the unstable performance of a single classifier, an ensemble learning method is employed. Since different classifiers have different preferences, even if one classifier makes a wrong prediction, the others will correct it. During initialization, different penalty parameters are applied. μ , build L Each base model of the TOS-ELM is assigned different weights based on its performance on new data. The classification performance of the ensemble system will decrease on new samples. Therefore, when the accuracy of the ensemble system is not up to standard, a new model is built to replace the model with the lowest weight to alleviate this problem. In classification problems, the standard for evaluating model performance is the model's classification accuracy. In the field of intrusion detection, attack samples are typically defined as positive classes, and normal samples as negative classes. The following four cases are defined: TP (True Instance), representing the number of correctly classified attack samples; TN (True Negative Instance), representing the number of correctly classified normal samples; FN (False Negative Instance), representing the number of normal samples misclassified as attack samples; and FP (False Positive Instance), representing the number of attack samples misclassified as normal samples. Accuracy is then expressed as: When the k Define cumulative accuracy when new data arrives. : in, For the first n The current iteration update number of the base classifier, based on the... n The base classifiers at the th... k Accuracy of new data And before The cumulative accuracy score of the round Calculated ; According to each model The following formula updates the model weights. : The initial value is 1 / L When the first n The cumulative total of the models Acc Fraction When the value is greater than the average, its weight increases; the higher the accuracy of the base model on new data samples, the higher its weight; penalty parameter μ A classifier whose value more accurately describes the similarity between the source and target domains will receive a higher ensemble weight; based on the weighted base model and the soft voting method, the output of the ensemble model is: in, For the first n Each base model for samples x Category m The predicted probability, for L After weighting and summing the outputs of the classifiers, the class with the highest probability is selected. m As the final output category.
2. The online intrusion detection method for intelligent pumped storage power stations based on model transfer as described in claim 1, characterized in that: Step S1 specifically includes the following steps: S101: Selection of dataset; The NSL-KDD dataset contains four attack types: DoS, Probe, U2R, R2L, and Normal. The NSL-KDD dataset contains the training set KDDTrain+ and the test dataset KDDTest+. KDDTest+ contains 17 new attack data belonging to the four attack types mentioned above, compared to KDDTrain+. Therefore, it is used as the experimental data. S102: Data preprocessing; Part of the R2L and U2R data in KDDTest+ were transferred to KDDTrain+ to make the class proportions in the two datasets roughly the same. The adjusted KDDTrain+ was used as the source domain dataset and KDDTest+ as the target domain dataset. One-hot encoding, data normalization, and two-dimensionalization were performed on the data in the target domain and the source domain to facilitate subsequent feature extraction.