Power grid violation behavior early warning method fusing TF-IDF and Bayesian algorithm
By integrating TF-IDF and Bayesian algorithm, keywords are extracted and weighted, and the early warning probability of violations is calculated, the problem of high subjectivity and high lag in the early warning method of grid violations is solved, and a higher warning is achieved Accuracy and timeliness.
Patent Information
- Application Number
- CN202411279165.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-02-18
AI Technical Summary
The existing early warning methods for power grid violations are highly subjective, highly lagging, low efficiency and high risk of omissions, and cannot effectively improve the accuracy and real-time nature of early warnings for violations.
Using a method of fusing TF-IDF and Bayesian algorithm, the violation behavior prediction database is constructed, keywords are extracted based on deep learning and weighted using TF-IDF algorithm to calculate the prior probability and conditional probability matrix of keywords, and the weight matrix is constructed. The final warning probability is calculated by combining the Bayesian algorithm.
It improves the accuracy and timeliness of early warning of power grid violations, reduces the subjectivity and lag of manual judgments, and enhances the overall effectiveness of the early warning system.
Smart Images

Figure CN119474701A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine learning, and in particular to a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm. Background Art
[0002] Traditional power grid violation warning methods mainly rely on manual experience and judgment, which can effectively identify violations to a certain extent. However, due to their reliance on personal experience and professional knowledge, they have obvious limitations in practical applications. The subjectivity of manual judgment leads to inconsistency in the judgment results. Different people may come to different conclusions due to personal cognitive differences. The lag of manual inspection makes it impossible for the warning system to capture potential violations in time, delaying the best time to take corresponding measures. With the growth of business scale, the workload of manual inspection becomes very heavy, which not only increases labor costs but also reduces work efficiency. In addition, when processing large amounts of data, it is difficult for manual inspection to ensure that no details are missed, which may result in important violations not being discovered in time. Therefore, traditional power grid violation warning methods can no longer meet the needs of efficiency and speed in the current big data environment.
[0003] By performing TF-IDF weighting on text data, we can highlight words that appear frequently in specific documents but less frequently in other documents, thereby better capturing key information, effectively screening out key words related to violations, improving the recognition ability of the model, and enhancing the Bayesian algorithm. By combining the results of TF-IDF with the prior probability and using the Bayesian theorem to update the posterior probability, the model can more accurately assess the possibility of violations, and use statistical information in historical data to improve the accuracy and reliability of early warnings through probabilistic reasoning. In addition, by integrating TF-IDF weighting on text data and enhancing the Bayesian algorithm, we can achieve real-time monitoring of violations and immediately issue an alarm when potential violations are predicted. Ultimately, we can detect potential violations in a timely manner and improve the timeliness and response speed of early warnings. Summary of the invention
[0004] In view of the above-mentioned problems, the present invention is proposed.
[0005] Therefore, the technical problem solved by the present invention is: the existing power grid violation behavior warning method has high subjectivity, high hysteresis, low efficiency, high risk of omission, and how to effectively improve the accuracy and real-time nature of the violation behavior warning, reduce the subjectivity and hysteresis of manual judgment, and improve the overall effectiveness of the warning system.
[0006] To solve the above technical problems, the present invention provides the following technical solutions: a power grid violation behavior warning method integrating TF-IDF and Bayesian algorithm, comprising constructing a violation behavior prediction database, extracting keywords based on deep learning and weighting the keywords using the TF-IDF algorithm; calculating the prior probability and conditional probability matrix of the keywords, constructing a weight matrix to calculate the weights between the keywords; inputting new data into the database, and calculating the final warning probability through the weight matrix and Bayesian algorithm.
[0007] As a preferred solution of the power grid violation behavior warning method integrating TF-IDF and Bayesian algorithm described in the present invention, the keyword extraction based on deep learning includes using a multi-head attention mechanism to extract keywords from historical power grid violation data through an attention-enhanced bidirectional long short-term memory network, and using a bidirectional LSTM layer to capture the bidirectional context information of the input sequence.
[0008] As a preferred solution of the power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm described in the present invention, the weighting of keywords using the TF-IDF algorithm includes calculating the frequency of occurrence of each keyword in the document in combination with word frequency statistics, and calculating the inverse document frequency of each keyword in the total document set of the database, and designing an improved TF-IDF scoring algorithm, which is expressed as:
[0009] TFIDF(t,d,D)=(1-β+β·TF(t,d))·IDF(t,D)
[0010] Where t is any word in the document, d is the document, D is the total document set in the database, β is the smoothing factor, and the value range of β is [0,1]. The dynamic TF-IDF scoring method based on neural network is expressed as:
[0011] Dynamic TFIDF(t,d,D)=NN(v t ,TF(t,d),IDF(t,D))
[0012] Among them, NN is a neural network model, v t is the word vector.
[0013] As a preferred solution of the power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm described in the present invention, the calculation of the prior probability and conditional probability matrix of keywords includes using Dirichlet distribution as the prior probability distribution of keywords, learning the hyperparameter α through the variational inference method, normalizing the word frequency of each keyword, using Logistic normalization and neural network model to fit the word frequency and probability, constructing a co-occurrence matrix and a conditional probability matrix, using a hidden Markov model to capture the sequential dependency between keywords, and using Bi-RNN to capture the bidirectional context information of the keyword sequence.
[0014] As a preferred solution of the power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm described in the present invention, wherein: the construction of the weight matrix includes using the PageRank algorithm to calculate the weights between keywords based on the prior probability and conditional probability matrix, expressed as:
[0015]
[0016] Among them, PR(k) is the PageRank value of keyword k, b is the damping factor, I k is the set of keywords pointing to keyword k, L(i) is the number of keywords pointed to by keyword i; construct the weight matrix between keywords, expressed as:
[0017]
[0018] Among them, W is the weight matrix between keywords, PR(w i →w j ) is the keyword w i To keyword w j The value of the weighted edge, j is a keyword different from keyword i.
[0019] As a preferred solution of the power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm described in the present invention, wherein: the inputting of new data into the database includes setting the prior data of the new data and modeling the prior probability using Dirichlet distribution, which is expressed as:
[0020]
[0021] Among them, P is the prior probability, π is the mixing coefficient, α is the Dirichlet distribution hyperparameter, and M is the number of mixing components. is the set of violation types in the mth mixed component, Γ is the gamma function, F c is the probability of violation type c; the dynamic update hyperparameter is designed, expressed as:
[0022] αr =α r-1 +η(f c,r -α r-1 )
[0023] Among them, α r is the hyperparameter at time r, f c,r is the frequency of violation type c observed at time r, and η is the learning rate.
[0024] As a preferred solution of the power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm described in the present invention, the calculation of the final early warning probability includes extracting the feature vector of the current operation, and calculating the likelihood probability of the violation type based on the feature vector and the weight matrix, which is expressed as:
[0025]
[0026] Among them, P′ is the likelihood probability, x is the feature vector, M is the number of mixed components, π cm is the weight of the mth mixture component, μ cm is the mean vector of the mth mixed component under violation type c, Σ cm is the covariance matrix of the mth mixed component under violation type c, and T is the transposition operation; based on the prior probability and likelihood probability, the posterior probability of the violation type is calculated, which is expressed as:
[0027]
[0028] Among them, P″ is the posterior probability, P′(x|c,m) is the likelihood probability when the violation type c and the mixed component m, and P is the evidence probability; the posterior probability is dynamically updated, which is expressed as:
[0029]
[0030] Among them, x r is the data observed at time r, P″(c|x r-1 ) is the posterior probability of the violation type c at time r-1; the posterior probability is weighted based on the weight matrix, expressed as:
[0031]
[0032] Among them, P final is the final warning probability, W ch is the weight between violation types c and h, and h is a violation type different from violation type c. The mutual influence between violation types is captured by the graph convolutional network, and the graph convolutional network is weighted and fused, which is expressed as:
[0033]
[0034] Among them, H (l) is the feature matrix of the lth layer, σ is the activation function, is the normalized adjacency matrix, W (l) is the weight matrix of the lth layer; the weight matrix is dynamically updated, expressed as:
[0035] w (r) =LSTM(W (r-1) ,x)
[0036] Among them, W (r) is the weight matrix at time r; through the multi-scale attention mechanism, the weights between different violation types are automatically adjusted, expressed as:
[0037] W = MultiHeadAttention(Q,K,V)
[0038] Among them, Q is the query matrix, K is the key matrix, and V is the value matrix. Based on the model complexity management mechanism of dynamic regularization, a regularization function is constructed, which is expressed as:
[0039]
[0040] Among them, L reg is the regularization function, λ is the dynamic regularization coefficient, θ is all the parameters of the model, N is the number of parameters, w u The weight factor assigned to each parameter; based on dynamic weight adjustment, the total loss function is constructed, expressed as:
[0041]
[0042] Among them, L total is the total loss function, is the loss function for each task, δ e (θ) is the dynamic weight of task e, and E is the number of tasks.
[0043] Another object of the present invention is to provide a power grid violation behavior warning system that integrates TF-IDF and Bayesian algorithm, which can solve the problem of low efficiency of current power grid violation behavior warning methods by inputting new data into the database and calculating the final warning probability through weight matrix and Bayesian algorithm.
[0044] As a preferred solution of the power grid violation behavior warning system integrating TF-IDF and Bayesian algorithm described in the present invention, it includes: a keyword weighting module, a priori probability matrix module, and a prediction and warning module; the keyword weighting module is used to build a violation behavior prediction database, extract keywords based on deep learning and use the TF-IDF algorithm to weight the keywords; the prior probability matrix module is used to calculate the prior probability and conditional probability matrix of the keywords, and construct a weight matrix to calculate the weights between the keywords; the prediction and warning module is used to input new data into the database, and calculate the final warning probability through the weight matrix and Bayesian algorithm.
[0045] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement a step of a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm.
[0046] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm.
[0047] The invention has the following beneficial effects: the power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm provided by the invention can more effectively capture key information in the historical violation data of the power grid through the multi-head attention mechanism and the bidirectional LSTM, thereby improving the accuracy of the early warning; the dynamic TF-IDF scoring method combines the word vector and the neural network, thereby more accurately reflecting the importance of the keywords in the document, thereby improving the intelligence of the early warning; by calculating the prior probability and conditional probability matrix of the keywords, the sequential dependency relationship between the keywords is captured, thereby improving the early warning system's ability to recognize the power grid violation behavior pattern; by constructing a weight matrix to calculate the weights between the keywords, the relative importance of the keywords in the power grid violation behavior early warning is improved, thereby improving the accuracy of the early warning; by adjusting the hyperparameters of the Dirichlet distribution in real time, the early warning system can adapt to changes in the power grid operating environment, thereby improving the adaptability of the early warning system; by dynamically updating the weight matrix and adopting the multi-scale attention mechanism, the weight can be dynamically adjusted according to the actual situation of the power grid violation behavior, thereby improving the flexibility and adaptability of the early warning system; by constructing a dynamic regularization and total loss function, it is helpful to manage the complexity of the model, prevent overfitting, and balance the importance of different tasks, thereby achieving better results in terms of accuracy, flexibility and adaptability. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0049] Figure 1 An overall flow chart of a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm provided in the first embodiment of the present invention;
[0050] Figure 2 A keyword co-occurrence matrix heat map of a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm provided in a second embodiment of the present invention;
[0051] Figure 3 A conditional probability and weight value diagram of keywords of a power grid violation warning method integrating TF-IDF and Bayesian algorithm provided in a second embodiment of the present invention;
[0052] Figure 4 A regularization coefficient and model performance line graph of a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm provided in a second embodiment of the present invention;
[0053] Figure 5 A multi-task learning loss curve diagram of a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm provided in the second embodiment of the present invention;
[0054] Figure 6 A confusion matrix diagram of a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm provided in the second embodiment of the present invention;
[0055] Figure 7 A schematic diagram of a module of a power grid violation warning system integrating TF-IDF and Bayesian algorithm provided in a third embodiment of the present invention. DETAILED DESCRIPTION
[0056] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.
[0057] Example 1, reference Figure 1, which is an embodiment of the present invention, provides a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm, including:
[0058] S1: Build a violation prediction database, extract keywords based on deep learning, and use the TF-IDF algorithm to weight the keywords.
[0059] Furthermore, deep learning-based keyword extraction includes using a multi-head attention mechanism to extract keywords from historical power grid violation data through an attention-enhanced bidirectional long short-term memory network, and using a bidirectional LSTM layer to capture the bidirectional contextual information of the input sequence.
[0060] It should be noted that the use of the TF-IDF algorithm to weight keywords includes calculating the frequency of occurrence of each keyword in the document in combination with word frequency statistics, and calculating the inverse document frequency of each keyword in the total document set of the database, and designing an improved TF-IDF scoring algorithm, which is expressed as:
[0061] TFIDF(t,d,D)=(1-β+β·TF(t,d))·IDF(t,D)
[0062] Where t is any word in the document, d is the document, D is the total document set in the database, β is the smoothing factor, and the value range of β is [0,1]. The dynamic TF-IDF scoring method based on neural network is expressed as:
[0063] Dynamic TFIDF(t,d,D)=NN(v t ,TF(t,d),IDF(t,D))
[0064] Among them, NN is a neural network model, v t is the word vector.
[0065] It should also be noted that the keyword extraction method based on the multi-head attention mechanism of deep learning and the bidirectional long short-term memory network provides a sophisticated and in-depth text analysis capability for the power grid violation warning system. The application of this method enables the implicit information in the historical violation data of the power grid to be effectively mined, thereby providing more accurate input features for the warning model. For example, through this mechanism, the system can identify the key factors that may lead to violations in the operation of the power grid, such as operating errors, equipment failures, etc. The extraction of these keywords lays a solid foundation for subsequent warning analysis. The improved TF-IDF scoring algorithm combines the smoothing factor β to effectively balance the influence of word frequency and inverse document frequency in the calculation of keyword weights. The innovation of this algorithm is that it not only takes into account the keywords The frequency of occurrence in a single document also takes into account its distribution in the entire document set, making the evaluation of the importance of keywords more comprehensive and objective. For example, through this algorithm, keywords that do not appear frequently but have important indicative significance will not be ignored, which plays a key role in the early identification and prevention of power grid violations. The dynamic TF-IDF scoring method based on neural networks further improves the dynamic adjustment ability of keyword weights by introducing word vectors and neural network models. It can adjust the weights of keywords in real time according to the actual operation of the power grid, so that the early warning system can adapt to changes in the power grid environment more flexibly. For example, during the peak load period of the power grid, the weights of certain keywords may be automatically increased, thereby improving the sensitivity of early warning to potential violations.
[0066] S2: By calculating the prior probability and conditional probability matrix of the keywords, a weight matrix is constructed to calculate the weights between the keywords.
[0067] Furthermore, calculating the prior probability and conditional probability matrix of keywords includes using Dirichlet distribution as the prior probability distribution of keywords, learning the hyperparameter α through variational inference method, normalizing the word frequency of each keyword, using Logistic normalization and neural network model to fit the word frequency and probability, constructing co-occurrence matrix and conditional probability matrix, using hidden Markov model to capture the sequential dependency between keywords, and using Bi-RNN to capture the bidirectional contextual information of keyword sequence.
[0068] It should be noted that constructing the weight matrix includes using the PageRank algorithm to calculate the weights between keywords based on the prior probability and conditional probability matrix, which is expressed as:
[0069]
[0070] Among them, PR(k) is the PageRank value of keyword k, b is the damping factor, I kis the set of keywords pointing to keyword k, L(i) is the number of keywords pointed to by keyword i; construct the weight matrix between keywords, expressed as:
[0071]
[0072] Among them, W is the weight matrix between keywords, PR(w i →w j ) is the keyword w i To keyword w j The value of the weighted edge, j is a keyword different from keyword i.
[0073] It should also be noted that by adopting Dirichlet distribution as the prior probability distribution of keywords and combining the variational inference method to learn hyperparameters, the present invention can more accurately estimate the probability of keywords in power grid violations, thereby providing a solid foundation for the early warning system. For example, this method can identify potential factors that may cause violations in power grid operation. By normalizing the word frequency and combining Logistic normalization and neural network models, the present invention can effectively convert the word frequency into probability, and then construct a co-occurrence matrix and conditional probability matrix reflecting the correlation of keywords. The weights between keywords are calculated by the PageRank algorithm, which adds a new dimension to the early warning system for power grid violations. It can identify key nodes in power grid data and quantify the importance of these nodes in the early warning system in the form of a weight matrix. For example, through the PageRank algorithm, keywords that play a key role in power grid violations will be given higher weights, thereby playing a greater role in early warning analysis. The constructed weight matrix between keywords not only reflects the independent importance of keywords, but also reveals the interactions and influences between them. This multi-dimensional analysis makes the early warning system more comprehensive and accurate, and can better serve the safety management of the power grid. For example, by analyzing the weight matrix, managers can identify which keyword linkages may lead to high-risk violations, thereby strengthening monitoring and prevention in a targeted manner.
[0074] S3: Input the new data into the database and calculate the final warning probability through the weight matrix and Bayesian algorithm.
[0075] Furthermore, inputting new data into the database includes setting the prior data of the new data and modeling the prior probability using the Dirichlet distribution, which is expressed as:
[0076]
[0077] Among them, P is the prior probability, π is the mixing coefficient, α is the Dirichlet distribution hyperparameter, and M is the number of mixing components. is the set of violation types in the mth mixed component, Γ is the gamma function, F c is the probability of violation type c; the dynamic update hyperparameter is designed, expressed as:
[0078] α r =α r-1 +η(f c,r -α r-1 )
[0079] Among them, α r is the hyperparameter at time r, f c,r is the frequency of violation type c observed at time r, and η is the learning rate.
[0080] It should be noted that the calculation of the final warning probability includes extracting the feature vector of the current operation, and calculating the likelihood probability of the violation type based on the feature vector and the weight matrix, which is expressed as:
[0081]
[0082] Among them, P′ is the likelihood probability, x is the feature vector, M is the number of mixed components, π cm is the weight of the mth mixture component, μ cm is the mean vector of the mth mixed component under violation type c, Σ cm is the covariance matrix of the mth mixed component under violation type c, and T is the transposition operation; based on the prior probability and likelihood probability, the posterior probability of the violation type is calculated, which is expressed as:
[0083]
[0084] Among them, P″ is the posterior probability, P′(x|c,m) is the likelihood probability when the violation type c and the mixed component m, and P is the evidence probability; the posterior probability is dynamically updated, which is expressed as:
[0085]
[0086] Among them, x r is the data observed at time r, P″(c|x r-1 ) is the posterior probability of the violation type c at time r-1; the posterior probability is weighted based on the weight matrix, expressed as:
[0087]
[0088] Among them, P final is the final warning probability, W chis the weight between violation types c and h, and h is a violation type different from violation type c. The mutual influence between violation types is captured by the graph convolutional network, and the graph convolutional network is weighted and fused, which is expressed as:
[0089]
[0090] Among them, H (l) is the feature matrix of the lth layer, σ is the activation function, is the normalized adjacency matrix, W (l) is the weight matrix of the lth layer; the weight matrix is dynamically updated, expressed as:
[0091] W (r) =LSTM(W (r-1) ,x)
[0092] Among them, W (r) is the weight matrix at time r; through the multi-scale attention mechanism, the weights between different violation types are automatically adjusted, expressed as:
[0093] W = MultiHeadAttention(Q,K,V)
[0094] Among them, Q is the query matrix, K is the key matrix, and V is the value matrix. Based on the model complexity management mechanism of dynamic regularization, a regularization function is constructed, which is expressed as:
[0095]
[0096] Among them, l reg is the regularization function, λ is the dynamic regularization coefficient, θ is all the parameters of the model, n is the number of parameters, w u The weight factor assigned to each parameter; based on dynamic weight adjustment, the total loss function is constructed, expressed as:
[0097]
[0098] Among them, L total is the total loss function, is the loss function for each task, δ e (θ) is the dynamic weight of task e, and E is the number of tasks.
[0099] It should also be noted that the method of dynamically updating hyperparameters ensures that the early warning system can continuously learn and adapt to changes in the power grid environment when processing real-time data. It provides timely and comprehensive information for the management of power grid violations, making the decision-making process more data-driven and improving management efficiency and effectiveness. By analyzing the frequency of violation types in power grid operations, the system can prevent future violations. Through the combination of feature vectors and weight matrices, a quantitative, probability-based evaluation is provided for the prediction of power grid violations. It can help managers accurately identify patterns and trends of violations in complex power grid environments, and then take corresponding preventive measures. Through the design of dynamic regularization and total loss functions, it ensures that the early warning model will not overfit during the training process, while maintaining good generalization ability. It can automatically adjust the learning parameters of the model according to the actual operation of the power grid to ensure the stability and reliability of the early warning system.
[0100] Example 2, reference Figure 2-Figure 6 , which is an embodiment of the present invention, provides a power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through simulation experiments.
[0101] First, the Attention-augmented BiLSTM model is used to extract keywords from the historical violation data of the power grid, including “power outage”, “overload”, “maintenance”, and “missing safety equipment”.
[0102] Step 1: Extract the above four keywords and use the TF-IDF algorithm to perform weighted scoring on the keywords. The keyword extraction results are shown in Table 1.
[0103] Table 1 Keywords and TF-IDF scores
[0104] Keywords Word frequency TF-IDF score power failure 150 0.85 overload 120 0.78 repair 110 0.74 Missing safety equipment 90 0.65
[0105] Step 2: Calculate the prior probability and conditional probability matrix of the keywords, construct a weight matrix to calculate the weights between keywords, and the prior probability and normalized probability of each keyword, as shown in Table 2.
[0106] Table 2 Prior probability and normalized probability of keywords
[0107] Keywords Prior probability Normalized probability power failure 0.2 0.6 overload 0.15 0.5 repair 0.12 0.45 Missing safety equipment 0.09 0.4
[0108] Figure 2 The heat map of keyword co-occurrence matrix is used to visualize the co-occurrence relationship between keywords in power grid violations. The horizontal and vertical axes represent different keywords, such as "power outage", "overload", "maintenance" and "lack of safety equipment". Figure 2The color depth of each grid in represents the co-occurrence frequency between the corresponding keywords. The darker the color, the more co-occurrence times. For example, Figure 2 The block between "power outage" and "overload" is darker in color, indicating that these two keywords often appear together in historical violation data, with a co-occurrence frequency of 5, indicating that overloading the power grid during a power outage is a common violation. Figure 2 It is used to help analyze the correlation between the keywords of various illegal behaviors and provide a reference for the weight calculation of the early warning model. This figure effectively verifies the authenticity and effectiveness of the keyword correlation analysis in the method of the present invention.
[0109] Figure 3 are the conditional probabilities and weight values of keywords, which are used to compare the conditional probabilities and weight values of each keyword. The horizontal axis lists different keywords, including "power outage", "overload", "maintenance" and "missing safety equipment", and the vertical axis represents the numerical values of the corresponding conditional probabilities and weight values. Each keyword corresponds to two columns, which represent the conditional probability and weight value of the keyword respectively. It can be seen from the figure that the conditional probability of the keyword "power outage" is 0.6, and the weight value is 0.7, indicating that it occupies an important position in the prediction of violation behavior. Relatively speaking, the conditional probability and weight value of the keyword "missing safety equipment" are lower, which are 0.2 and 0.4 respectively, indicating that it has less influence in the model.
[0110] Step 3: Input the new data into the database, and calculate the final warning probability, posterior probability and weighted probability through the weight matrix and Bayesian algorithm, as shown in Table 3.
[0111] Table 3 Posterior probability and weighted probability
[0112] Keywords Posterior probability Weighted probability power failure 0.75 0.80 overload 0.65 0.70 repair 0.50 0.55 Missing safety equipment 0.40 0.45
[0113] Figure 4 It is a line graph of regularization coefficient and model performance, which is used to analyze the impact of different regularization coefficients λ on model performance. The horizontal axis represents different values of the regularization coefficient λ, ranging from 10 -3 to 10 2 , using a logarithmic scale, the vertical axis represents the accuracy of the model, from Figure 4 It can be seen from the figure that as the value of λ increases, the performance of the model first increases and then decreases. -1 When λ is close to , the model performance reaches the highest point, with an accuracy of about 0.89, which shows that under this regularization coefficient, the model has achieved the best balance between preventing overfitting and underfitting. However, when λ continues to increase or decrease, the performance of the model begins to decline, indicating that too strong or too weak regularization will have a negative impact on the model performance. Figure 4 It clearly demonstrates the importance of the choice of regularization coefficient to model performance, providing a strong basis for optimizing the model.
[0114] Figure 5 It is a multi-task learning loss curve, which is used to show the change of loss of different tasks during the training process. The horizontal axis represents the training round (Epochs), from 1 to 10, and the vertical axis represents the loss value. Figure 5 There are three curves in the figure, representing the loss change trends of three different tasks. It can be seen that with the increase of training rounds, the loss values of all tasks gradually decrease, indicating that the model is constantly learning and optimizing. Task 1 (solid line) has the fastest decrease in loss value. At the 10th training round, the loss value is close to 0.4, indicating that Task 1 has the best learning effect. Task 2 (dashed line) has a relatively stable decrease in loss value, which eventually reaches about 0.7, and the performance is second. Task 3 (dotted line) has the slowest decrease in loss value, which eventually reaches about 0.8, and the learning effect is the worst. Overall, Figure 5 It shows that in the multi-task learning framework, the loss values of different tasks tend to decrease as training progresses. The model has different adaptability and learning speeds for different tasks. By analyzing these loss curves, the multi-task learning strategy can be further optimized.
[0115] Figure 6 It is a confusion matrix, which is an intuitive display of the prediction performance of the power grid violation behavior warning model, and verifies the accuracy and reliability of the method of the present invention in practical applications. In the confusion matrix, the horizontal axis represents the label predicted by the model, and the vertical axis represents the actual real label. The values in the matrix represent the number of samples under each category. The values on the diagonal, i.e., "4" in the upper left corner and "4" in the lower right corner, represent the number of samples correctly predicted by the model, indicating that the model performs well in these two categories. The values on the off-diagonal, i.e., "1" in the upper right corner and "1" in the lower left corner, represent the number of samples predicted incorrectly by the model, indicating that the model has certain errors in these aspects. Overall, the number of correct classifications in the confusion matrix is relatively high, which proves that the method invented by our party has high accuracy in power grid violation behavior warning, and effectively verifies the authenticity of the experimental results. Therefore, our invention is creative.
[0116] Example 3, reference Figure 7 , which is an embodiment of the present invention, provides a power grid violation behavior warning system integrating TF-IDF and Bayesian algorithm, including a keyword weighting module, a priori probability matrix module, and a prediction and warning module.
[0117] The keyword weighting module is used to build a violation prediction database, extract keywords based on deep learning, and use the TF-IDF algorithm to weight the keywords; the prior probability matrix module is used to calculate the prior probability and conditional probability matrix of the keywords, and build a weight matrix to calculate the weights between keywords; the prediction and warning module is used to input new data into the database and calculate the final warning probability through the weight matrix and Bayesian algorithm.
[0118] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0119] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0120] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering, or processing in another suitable manner as necessary, and then stored in a computer memory.
[0121] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc. It should be noted that the above embodiments are only used to illustrate the technical solution of the present invention and are not limited. Although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.
[0122] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm, characterized in that: include: Build a violation behavior prediction database, extract keywords based on deep learning, and use the TF-IDF algorithm to weight keywords; By calculating the prior probability and conditional probability matrix of keywords, a weight matrix is constructed to calculate the weights between keywords; The new data is input into the database, and the final warning probability is calculated through the weight matrix and Bayesian algorithm.
2. The power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm as claimed in claim 1 is characterized by: The deep learning-based keyword extraction includes using a multi-head attention mechanism to extract keywords from historical power grid violation data through an attention-enhanced bidirectional long short-term memory network, and using a bidirectional LSTM layer to capture bidirectional context information of the input sequence.
3. The power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm as claimed in claim 2 is characterized by: The use of the TF-IDF algorithm to weight keywords includes calculating the frequency of occurrence of each keyword in the document in combination with word frequency statistics, and calculating the inverse document frequency of each keyword in the total document set of the database, and designing an improved TF-IDF scoring algorithm, which is expressed as: TFIDF(t,d,D)=(1-β+β·TF(t,d))·IDF(t,D) Where t is any word in the document, d is the document, D is the total document set in the database, β is the smoothing factor, and the value range of β is [0,1]; The dynamic TF-IDF scoring method based on neural network is expressed as: Dynamic TFIDF(t,d,D)=NN(v t ,TF(t,d),IDF(t,D)) Among them, NN is a neural network model and vt is a word vector.
4. The power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm as claimed in claim 3 is characterized by: The method for calculating the prior probability and conditional probability matrix of keywords includes using Dirichlet distribution as the prior probability distribution of keywords, learning the hyperparameter α through the variational inference method, normalizing the word frequency of each keyword, using Logistic normalization and a neural network model to fit the word frequency and probability, constructing a co-occurrence matrix and a conditional probability matrix, using a hidden Markov model to capture the sequential dependency between keywords, and using Bi-RNN to capture the bidirectional context information of the keyword sequence.
5. The power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm as claimed in claim 4 is characterized by: The construction of the weight matrix includes calculating the weights between keywords using the PageRank algorithm based on the prior probability and conditional probability matrix, which is expressed as: Among them, PR(k) is the PageRank value of keyword k, b is the damping factor, I k is the set of keywords pointing to keyword k, L(i) is the number of keywords pointed to by keyword i; Construct the weight matrix between keywords, expressed as: Among them, W is the weight matrix between keywords, PR(w i →w j ) is the keyword w i To keyword w j The value of the weighted edge, j is a keyword different from keyword i.
6. The power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm as claimed in claim 5 is characterized by: The inputting of new data into the database includes setting the prior data of the new data and modeling the prior probability using Dirichlet distribution, which is expressed as: Among them, P is the prior probability, π is the mixing coefficient, α is the Dirichlet distribution hyperparameter, and M is the number of mixing components. is the set of violation types in the mth mixed component, Γ is the gamma function, F c is the probability of violation type c; Design dynamic update hyperparameters, expressed as: a r =a r-1 +η(f c,r -a r-1 ) Among them, α r is the hyperparameter at time r, f c,r is the frequency of violation type c observed at time r, and η is the learning rate.
7. The power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm as claimed in claim 6 is characterized by: The calculation of the final warning probability includes extracting the feature vector of the current operation, and calculating the likelihood probability of the violation type based on the feature vector and the weight matrix, which is expressed as: Among them, P′ is the likelihood probability, x is the feature vector, M is the number of mixed components, π cm is the weight of the mth mixture component, μ cm is the mean vector of the mth mixed component under violation type c, Σ cm is the covariance matrix of the mth mixed component under violation type c, and T is the transpose operation; Based on the prior probability and likelihood probability, the posterior probability of the violation type is calculated, which is expressed as: Where P" is the posterior probability, P′(x|c,m) is the likelihood probability for violation type c and mixed component m, and P is the evidence probability; The design dynamically updates the posterior probability, expressed as: Among them, x r is the data observed at time r, P"(c|x r-1 ) is the posterior probability of violation type c at time r-1; The posterior probability is weighted based on the weight matrix, expressed as: Among them, P final is the final warning probability, W ch is the weight between violation types c and h, h is a violation type different from violation type c; The mutual influence between violation types is captured through graph convolutional networks, and the graph convolutional networks are weighted and fused, which can be expressed as: Among them, H (l) is the feature matrix of the lth layer, σ is the activation function, is the normalized adjacency matrix, W (l) is the weight matrix of the lth layer; Design a dynamic update weight matrix, expressed as: W (r) =LSTM(W (r-1) ,x) Among them, W (r) is the weight matrix at time r; Through the multi-scale attention mechanism, the weights between different violation types are automatically adjusted, expressed as: W = MultiHeadAttention(Q,K,V) Among them, Q is the query matrix, K is the key matrix, and V is the value matrix; Based on the model complexity management mechanism of dynamic regularization, a regularization function is constructed, which is expressed as: Among them, L reg is the regularization function, λ is the dynamic regularization coefficient, θ is all the parameters of the model, N is the number of parameters, w u The weight factor assigned to each parameter; Based on dynamic weight adjustment, the total loss function is constructed and expressed as: Among them, L total is the total loss function, is the loss function for each task, δ e (θ) is the dynamic weight of task e, and E is the number of tasks.
8. A system using the power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm as claimed in any one of claims 1 to 7, characterized in that: Including keyword weighting module, prior probability matrix module, prediction and warning module; The keyword weighting module is used to build a traffic violation prediction database, extract keywords based on deep learning and use the TF-IDF algorithm to weight the keywords; The prior probability matrix module is used to calculate the prior probability and conditional probability matrix of the keywords and construct a weight matrix to calculate the weights between the keywords; The prediction and warning module is used to input new data into the database and calculate the final warning probability through the weight matrix and Bayesian algorithm.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the power grid violation behavior early warning method integrating TF-IDF and Bayesian algorithm according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Government affair text data classification processing system and method based on knowledge graph
CN119807420A