Intelligent labeling and classifying method for HSE system audit data, medium and electronic equipment
By adopting the HSE system to review data intelligent annotation classification method in the oil and gas industry, the problem of low data annotation efficiency and quality of the HSE system in this industry has been solved, the efficiency and quality of data annotation are improved, and the interpretability and ability of the learning model are enhanced. Controlled.
Patent Information
- Application Number
- CN202310924698.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-26
- Publication Date
- 2025-02-07
AI Technical Summary
The data labeling efficiency and quality of the HSE system in the oil and gas industry affects the application effect and learning ability of artificial intelligence.
The HSE system is used to review the data intelligent annotation classification method, and improve the efficiency and quality of data annotation through text preprocessing, feature word selection, data classification model establishment and hyperparameter optimization.
It improves the efficiency and quality of data annotation, enhances the interpretability and controllability of the learning model, and reduces labor costs and error rates.
Smart Images

Figure CN119397013A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, medium and electronic device for intelligently labeling and classifying HSE system audit data. Background Art
[0002] The safety production guarantee of the oil and gas industry involves the entire industry chain and the entire life cycle of exploration and development, oil and gas storage and transportation, purification and refining, terminal gas sales, etc. Therefore, the industry generally promotes a similar HSE (Health, Safety, Environment) management system model. With the deepening of the digital transformation of the oil and gas field industry, domestic artificial intelligence technology has been gradually applied to the industry business, but the oil and gas industry has a large professional span, limited data collection technology, data sharing and collaboration difficulties, lack of data diversity and representativeness, and inconsistent data quality and standards, which affects the application effect of artificial intelligence and poor learning ability.
[0003] Artificial intelligence learning requires data. It is necessary to research and develop a series of intelligent labeling and classification methods for HSE data in the oil and gas field to improve the efficiency and quality of data labeling, reduce labor costs and error rates, and promote the application and development of artificial intelligence in the oil and gas industry. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method, medium and electronic equipment for intelligent labeling and classification of HSE system audit data, so as to improve the efficiency and quality of HSE system data labeling, especially in the oil and gas industry, and to improve the interpretability and controllability of the learning model.
[0005] The technical solution adopted by the present invention to solve the technical problem is: a method for intelligent labeling and classification of HSE system audit data, comprising the following steps:
[0006] S1. Collect text documents of HSE system audit reports and audit question lists;
[0007] S2. Preprocessing the text of the document, including:
[0008] S21, extracting proper nouns from the document text and establishing a custom industry vocabulary;
[0009] S22, performing word segmentation processing on the text in the document in combination with a custom industry vocabulary to obtain a vocabulary table V;
[0010] S23, calculate the TF-IDF value tfidf(w,d) of each word w in each document d;
[0011] S24, calculating the information gain value ig(w,c) of each word w in different categories c of the document;
[0012] S25, calculate the product of the TF-IDF value and the information gain value of each word w, obtain the feature score of each word w, and sort the vocabulary V according to the feature score of each word w, and select the words whose feature scores are greater than or equal to the set initial threshold parameter θ 0 The words are used as feature words, and the rest are used as stop words;
[0013] S26, after removing stop words, recalculate the vector representation of the document and category and extract the text;
[0014] S3. Use an applicable algorithm to establish a data classification model for the extracted text results;
[0015] S4. Optimizing the model using hyperparameters;
[0016] S5. Evaluate the model. If the model meets the requirements, automatically label and classify the data. If not, adjust the initial threshold parameter θ. 0 , repeat steps S25, S26, S3, S4 and S5.
[0017] Furthermore, the step of S1, collecting HSE system audit report and audit question list documents, includes:
[0018] S11. Historical HSE system audit reports and audit question lists are directly stored in the memory;
[0019] S12. The newly added data of HSE audit is connected to the storage device by the information system.
[0020] Furthermore, tfidf(w,d)=tf(w,d)×idf(w), where tf(w,d) is the frequency of word w in document d, and idf(w) is the inverse document frequency of word w.
[0021]
[0022] Among them, df(w) contains the number of documents of word w, and then each document d is vectorized, that is,
[0023] Furthermore, ig(w,c)=H(c)-H(c|w), where H(c) is the information entropy of category c, i.e. p(c i ) is the probability of category i, that is, the number of documents in this category divided by the total number of documents, and H(c|w) is the conditional information entropy of category c given word w, that is,
[0024] H(c|w)=p(w)H(c|w=1)+(1-p(w))H(c|w=0)
[0025] Among them, p(w) is the probability of word w appearing, that is, the number of documents containing word w divided by the total number of documents, H(c|w=1) and H(c|w=0) are the information entropy of category c when word w appears and does not appear.
[0026]
[0027]
[0028] in,
[0029] in, df(w,c i ) is the number of documents that contain word w and belong to category i, and df(c i ) is the number of documents belonging to category i, and vectorizes each category c
[0030] Furthermore, the step S3, using an applicable algorithm to establish a data classification model for the extracted text results, includes:
[0031] S31, divide the training set and the test set into a ratio of 8:2;
[0032] S32. Use the XGBoost algorithm to build a classification model on the training set.
[0033] Furthermore, the step of optimizing the model using hyperparameters in S4 includes:
[0034] S41, the learning rate of XGBoost is set to [1e -3 ,1e -1 ], using log-uniform function distribution, the ideal curve is adjusted according to the probability density function and the uniform distribution of variables;
[0035] S42, the number of decision trees is set to a hyperparameter of (100, 2000), the maximum depth of the decision tree is set to a hyperparameter range of (3, 30), the minimum number of samples after the leaf node is set to a candidate value range of (1, 10), the subsampling weak trainer is set to a range of (0.5, 1), the minimum range of the loss reduction required for the leaf node to branch is set to (0, 0.5), and the sampling feature ratio of the decision tree is controlled to (0.5, 1);
[0036] S43, after n iterations, find a set of parameters with the smallest iterative loss function.
[0037]
[0038] Among them, θ is the parameter to be solved, L(θ).stθ is the iterative loss function, and θ 0is the initial threshold parameter, a i is the learning rate of the i-th word iteration, g i is the gradient direction of the ith iteration, and n is the number of iterations.
[0039] Furthermore, in S5, the model is evaluated. If the model meets the requirements, the data is automatically labeled and classified. If not, the initial threshold parameter θ is adjusted. 0 , repeating steps S25, S26, S3, S4 and S5 comprises:
[0040] Evaluate whether the minimum iterative loss function minL(θ).stθ after n iterations meets the requirements. If it meets the requirements, use the code to generate a .pkl file, and call the file for automatic data labeling and classification. If it does not meet the expected requirements, adjust the initial threshold parameter θ 0 , repeat steps S25, S26, S3, S4 and S5.
[0041] Furthermore, the number of iterations n is 800.
[0042] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed, the method for intelligently labeling and classifying HSE system audit data is performed.
[0043] The present invention also provides an electronic device, comprising:
[0044] a memory having a computer program stored thereon; and
[0045] A processor is connected to the memory and is used to execute the above-mentioned method for intelligent labeling and classification of HSE system audit data when calling the computer program.
[0046] The beneficial effects of the present invention are as follows: the intelligent labeling and classification method, medium and electronic device of the present invention for HSE system audit data, the labeling and classification method adopts the method of multiplying the TF-IDF value and the information gain value, and selecting the feature word according to the size of the product. Compared with the method based on word frequency, the method of multiplying the TF-IDF value and the information gain value can better reflect the importance and distinguishing ability of words in documents and categories, reduce the influence of common words and irrelevant words, and improve the quality of features and the accuracy of classification;
[0047] Compared with the statistical test-based method, the method of multiplying the TF-IDF value and the information gain value can better consider the distribution of words in the document, rather than just the distribution of words in the category, and avoids ignoring some words that are important in certain documents;
[0048] Compared with the topic model-based method, the method of multiplying the TF-IDF value and the information gain value can more directly utilize the semantic information of the word itself without the need to represent documents and categories through potential topics, which simplifies the calculation process and reduces the complexity of parameter adjustment;
[0049] Compared with deep learning-based methods, the method of multiplying TF-IDF value and information gain value can more easily explain and understand the basis and results of feature selection without relying on complex neural network structure and training process, which improves interpretability and controllability. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 It is a flow chart of a method for intelligently labeling and classifying HSE system audit data of the present invention;
[0051] Figure 2 It is a line chart of the change in the loss value of XGBoost parameter tuning;
[0052] Figure 3 It is the accuracy iteration graph of random forest. DETAILED DESCRIPTION
[0053] The present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0054] like Figure 1 , Figure 2 As shown, a method for intelligently labeling and classifying HSE system audit data of the present invention comprises the following steps:
[0055] S1. Collect text documents of HSE system audit reports and audit question lists;
[0056] S2. Preprocessing the text of the document, including:
[0057] S21, using the regular expression ".*" to extract proper nouns in the document text and establish a custom industry vocabulary;
[0058] S22, performing word segmentation processing on the text in the document in combination with a custom industry vocabulary to obtain a vocabulary table V;
[0059] S23, calculate the TF-IDF value tfidf(w,d) of each word w in each document d of the document;
[0060] S24, calculating the information gain value ig(w,c) of each word w in different document categories c of the document according to the category of the document;
[0061] S25, calculate the product of the TF-IDF value and the information gain value of each word w, obtain the feature score of each word w, and sort the vocabulary V according to the feature score of each word w, and select the words whose feature scores are greater than or equal to the set initial threshold parameter θ 0 The words that meet the following conditions are used as feature words: tfidf(w,d)×ig(w,c)≥θ 0 ;
[0062] S26, after removing stop words, recalculate the vector representation of the document and category and extract the text;
[0063] S3. Use an applicable algorithm to establish a data classification model for the extracted text results;
[0064] S4. Optimizing the model using hyperparameters;
[0065] S5. Evaluate the model. If the model meets the requirements, automatically label and classify the data. If not, adjust the initial threshold parameter θ. 0 , repeat steps S25, S26, S3, S4 and S5.
[0066] The present invention adopts a method of multiplying TF-IDF value and information gain value, and selecting feature words according to the size of the product, which can better reflect the importance and distinguishing ability of words in documents and categories, reduce the influence of common words and irrelevant words, and improve the quality of features and the accuracy of classification. Compared with the method based on statistical test, the method of multiplying TF-IDF value and information gain value can better consider the distribution of words in documents, rather than just the distribution of words in categories, and avoids ignoring some words that are important in certain documents. Compared with the method based on topic model, the method of multiplying TF-IDF value and information gain value can more directly utilize the semantic information of the word itself, without the need to represent documents and categories through potential topics, simplifying the calculation process and reducing the complexity of parameter adjustment. Compared with the method based on deep learning, the method of multiplying TF-IDF value and information gain value can more easily explain and understand the basis and results of feature selection, without relying on complex neural network structure and training process, and improving interpretability and controllability.
[0067] Specifically, the step of S1, collecting HSE system audit report and audit question list documents, includes:
[0068] S11. Historical HSE system audit reports and audit question lists are directly stored in the memory;
[0069] S12. The newly added data of HSE audit is connected to the storage device by the information system.
[0070] Specifically, the TF-IDF value of each word w in each document d is tfidf(w,d)=tf(w,d)×idf(w), where tf(w,d) is the frequency of word w in document d, and idf(w) is the inverse document frequency of word w.
[0071]
[0072] Among them, df(w) contains the number of documents of word w, and then each document d is vectorized, that is,
[0073]
[0074] The information gain value of each word w in different categories c is ig(w,c)=H(c)-H(c|w), where H(c) is the information entropy of category c, that is, p(c i ) is the probability of category i, that is, the number of documents in this category divided by the total number of documents, and H(c|w) is the conditional information entropy of category c given word w, that is,
[0075] H(c|w)=p(w)H(c|w=1)+(1-p(w))H(c|w=0)
[0076] Among them, p(w) is the probability of word w appearing, that is, the number of documents containing word w divided by the total number of documents, H(c|w=1) and H(c|w=0) are the information entropy of category c when word w appears and does not appear.
[0077]
[0078]
[0079] in,
[0080] in, df(w,c i ) is the number of documents that contain word w and belong to category i, and df(c i ) is the number of documents belonging to category i, and vectorizes each category c
[0081] In the embodiment of the present invention, the step S3, using an applicable algorithm to establish a data classification model for the extracted text results, specifically includes:
[0082] S31, divide the training set and the test set into a ratio of 8:2;
[0083] S32. Use the XGBoost algorithm to build a classification model on the training set.
[0084] In the embodiment of the present invention, S4, the step of optimizing the model using hyperparameters specifically includes:
[0085] S41. Set the learning rate of XGBoost to [1e -3 ,1e -1 ], using log-uniform function distribution, the ideal curve is adjusted according to the probability density function and the uniform distribution of variables;
[0086] S42, the number of decision trees (n_estimators) is set to a hyperparameter of (100, 2000), the maximum depth of the decision tree (max_depth) is set to a hyperparameter range of (3, 30), the minimum number of samples of leaf nodes (min_child_weight) is set to a candidate value range of (1, 10), the subsampling weak trainer (subsample) is set to a range of (0.5, 1), the minimum range of loss reduction required for leaf nodes to branch is set to (0, 0.5), and the sampling feature ratio of the decision tree (colsample_bytree) is controlled to (0.5, 1);
[0087] S43. After n iterations, find a set of parameters that minimizes the iterative loss function.
[0088]
[0089] Among them, θ is the parameter to be solved, L(θ).stθ is the iterative loss function, and θ 0 is the initial threshold parameter, a i is the learning rate of the i-th word iteration, g i is the gradient direction of the ith iteration, and n is the number of iterations. The number of iterations n can be set randomly. In the embodiment of the present invention, the number of iterations n is set to 800.
[0090] S5: Evaluate the model. If the model meets the requirements, automatically label and classify the data. If not, adjust the initial threshold parameter θ. 0 , repeating steps S25, S26, S3, S4 and S5. The steps specifically include: evaluating whether the minimum iterative loss function minL(θ).stθ after n iterations meets the requirements. If it meets the requirements, the code is used to generate a .pkl file, and the file is called for automatic data labeling and classification. If it does not meet the expected requirements, the initial threshold parameter θ is adjusted. 0 , repeat steps S25, S26, S3, S4 and S5.
[0091] The present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the above-mentioned HSE system audit data intelligent labeling and classification method is executed. The storage medium can be a read-only memory, a disk or an optical disk, etc.
[0092] The present invention also provides an electronic device, such as a smart phone, tablet computer, laptop computer, desktop computer, etc. that can execute programs, comprising: a memory on which a computer program is stored; and a processor connected to the memory, for executing the above-mentioned method for intelligent labeling and classification of HSE system audit data when calling the computer program.
[0093] Example:
[0094] S1. Collect the text documents of HSE system audit report and audit question list, see Table 1;
[0095] Table 1 Text documents of HSE system audit report and audit question list
[0096]
[0097]
[0098] S2. Use the following industry dictionaries to establish a custom library, and use the TF-IDF and information gain product of the word segmentation text to pre-process the text of the HSE system audit report and the audit question list in Table 1. The processing results are shown in Table 2.
[0099]
[0100] Table 2 Partial display of text preprocessing results
[0101]
[0102]
[0103] S3. Establish data classification model:
[0104] S31, divide the training set and the test set into a ratio of 8:2;
[0105] S32. Use the XGBoost algorithm to build a classification model on the training set.
[0106] S4. Optimize the model using hyperparameters:
[0107] S41, the learning rate of XGBoost is set to [1e -3 ,1e -1 ], using log-uniform function distribution, the ideal curve is adjusted according to the probability density function and the uniform distribution of variables;
[0108] S43, the number of decision trees is set to a hyperparameter of (100, 2000), the maximum depth of the decision tree is set to a hyperparameter range of (3, 30), the minimum number of samples after the leaf node is set to a candidate value range of (1, 10), the subsampling weak trainer is set to a range of (0.5, 1), the minimum range of the loss reduction required for the leaf node to branch is set to (0, 0.5), and the sampling feature ratio of the decision tree is controlled to (0.5, 1);
[0109] S42, after 800 iterations, the accuracy iteration graph of XGBoost is shown in Figure 2 After 800 iterations, the minimum average value of the iterative loss function is 0.7579. The parameter combination that minimizes the average value of the loss function is shown in Table 3:
[0110] Table 3 XGBoost optimal parameters
[0111]
[0112]
[0113] The accuracy of the XGBoost classification model established with this hyperparameter reaches 80%. The XGBoost classification model is used for testing, and the confusion matrix of the test set is shown in Table 4:
[0114] Table 4 Confusion matrix of XGBoost test set results
[0115]
[0116]
[0117]
[0118] Comparative Example
[0119] The accuracy iteration graph using random forest is shown in Figure 3 ,Depend on Figure 3 As shown in Table 5, after 800 iterations, the minimum average value of the iterative loss function is 1.0855. The parameter combination that minimizes the average value of the loss function is shown in Table 5:
[0120] Table 5 Optimal parameters of random forest
[0121]
[0122] From the above, it can be seen that the lowest average value of the iterative loss function after optimization using the method of the present invention is 0.7579, while the lowest average value of the iterative loss function using random forest is 1.0855. The average value of the iterative loss function of the present invention is much smaller than the average value of the iterative loss function using random forest, and the accuracy of the present invention is higher.
Claims
1. A method for intelligent labeling and classification of HSE system audit data, characterized in that: The following steps are involved: S1. Collect text documents of HSE system audit reports and audit question lists; S2. Preprocessing the text of the document, including: S21, extracting proper nouns from the document text and establishing a custom industry vocabulary; S22, performing word segmentation processing on the text in the document in combination with a custom industry vocabulary to obtain a vocabulary table V; S23, calculate the TF-IDF value tfidf(w,d) of each word w in each document d; S24, calculating the information gain value ig(w,c) of each word w in different categories c of the document; S25, calculating the product of the TF-IDF value and the information gain value of each word w to obtain the feature score of each word w, and sorting the vocabulary V according to the feature score of each word w, and selecting the words that satisfy the feature score greater than or equal to the set initial threshold parameter θ0 as feature words, and the rest as stop words; S26, after removing stop words, recalculate the vector representation of the document and category and extract the text; S3. Use an applicable algorithm to establish a data classification model for the extracted text results; S4. Optimizing the model using hyperparameters; S5. Evaluate the model. If the model meets the requirements, automatically label and classify the data. If not, adjust the initial threshold parameter θ0 and repeat steps S25, S26, S3, S4 and S5.
2. The method for intelligent labeling and classification of HSE system audit data according to claim 1, characterized in that: The steps of S1, collecting HSE system audit report and audit question list documents, include: S11. Historical HSE system audit reports and audit question lists are directly stored in the memory; S12. The newly added data of HSE audit is connected to the storage device by the information system.
3. The method for intelligent labeling and classification of HSE system audit data according to claim 1, characterized in that: tfidf(w,d)=tf(w,d)×idf(w), where tf(w,d) is the frequency of word w in document d, and idf(w) is the inverse document frequency of word w. Among them, df(w) contains the number of documents of word w, and then each document d is vectorized, that is, 4. A method for intelligent labeling and classification of HSE system audit data as claimed in claim 1 or 3, characterized in that: ig(w,c)=H(c)-H(c|w), where H(c) is the information entropy of category c, i.e. p(c i ) is the probability of category i, that is, the number of documents in this category divided by the total number of documents, and H(c|w) is the conditional information entropy of category c given word w, that is, H(c|w)=p(w)H(c|w=1)+(1-p(w))H(c|w=0) Among them, p(w) is the probability of word w appearing, that is, the number of documents containing word w divided by the total number of documents, H(c|w=1) and H(c|w=0) are the information entropy of category c when word w appears and does not appear, that is, in, in, df(w,c i ) is the number of documents that contain word w and belong to category i, and df(c i ) is the number of documents belonging to category i, and vectorizes each category c 5. The method for intelligent labeling and classification of HSE system audit data according to claim 1, characterized in that: The step S3, using an applicable algorithm to establish a data classification model for the extracted text results, comprises: S31, divide the training set and the test set into a ratio of 8:2; S32. Use the XGBoost algorithm to build a classification model on the training set.
6. The method for intelligent labeling and classification of HSE system audit data according to claim 5, characterized in that: The step of optimizing the model using hyperparameters in S4 includes: S41, the learning rate of XGBoost is set to [1e -3 ,1e -1 ], using log-uniform function distribution, the ideal curve is adjusted according to the probability density function and the uniform distribution of variables; S42, the number of decision trees is set to a hyperparameter of (100, 2000), the maximum depth of the decision tree is set to a hyperparameter range of (3, 30), the minimum number of samples after the leaf node is set to a candidate value range of (1, 10), the subsampling weak trainer is set to a range of (0.5, 1), the minimum range of the loss reduction required for the leaf node to branch is set to (0, 0.5), and the sampling feature ratio of the decision tree is controlled to (0.5, 1); S43. After n iterations, find a set of parameters with the smallest iterative loss function: Among them, θ is the parameter to be solved, L(θ).stθ is the iterative loss function, θ0 is the initial threshold parameter, and a i is the learning rate of the i-th word iteration, g i is the gradient direction of the i-th iteration, and n is the number of iterations.
7. The method for intelligent labeling and classification of HSE system audit data according to claim 6, characterized in that: S5, evaluating the model, if the model meets the requirements, automatically marking and classifying the data, if not, adjusting the initial threshold parameter θ0, and repeating steps S25, S26, S3, S4 and S5. The steps include: Evaluate whether the minimum iterative loss function minL(θ).stθ after n iterations meets the requirements. If so, generate a .pkl file using code, and call the file for automatic data labeling and classification. If not, adjust the initial threshold parameter θ0 and repeat steps S25, S26, S3, S4 and S5.
8. The method for intelligent labeling and classification of HSE system audit data according to claim 6, characterized in that: The number of iterations n is 800.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, a method for intelligent labeling and classification of HSE system audit data according to any one of claims 1 to 8 is performed.
10. An electronic device, characterized in that: include: a memory having a computer program stored thereon; and A processor is connected to the memory and is used to execute the method for intelligent labeling and classification of HSE system audit data as described in any one of claims 1 to 8 when calling the computer program.