CN114756656A - Mining method of association rules for hydraulic engineering safety hazard description based on improved Apriori algorithm - Google Patents
Mining method of association rules for hydraulic engineering safety hazard description based on improved Apriori algorithm Download PDFInfo
- Publication number
- CN114756656A CN114756656A CN202210471547.4A CN202210471547A CN114756656A CN 114756656 A CN114756656 A CN 114756656A CN 202210471547 A CN202210471547 A CN 202210471547A CN 114756656 A CN114756656 A CN 114756656A
- Authority
- CN
- China
- Prior art keywords
- data
- item set
- matrix
- item
- hydraulic engineering
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000005065 mining Methods 0.000 title claims abstract description 21
- 238000000034 method Methods 0.000 title claims abstract description 18
- 239000011159 matrix material Substances 0.000 claims abstract description 34
- 230000011218 segmentation Effects 0.000 claims abstract description 28
- 238000012216 screening Methods 0.000 claims abstract description 8
- 238000013138 pruning Methods 0.000 claims description 5
- 238000006243 chemical reaction Methods 0.000 claims description 3
- 238000004364 calculation method Methods 0.000 claims description 2
- 238000002372 labelling Methods 0.000 claims 1
- 230000036651 mood Effects 0.000 claims 1
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 abstract description 28
- 238000011835 investigation Methods 0.000 abstract description 3
- 238000007781 pre-processing Methods 0.000 abstract description 2
- 238000010276 construction Methods 0.000 description 8
- 238000000605 extraction Methods 0.000 description 7
- 238000001914 filtration Methods 0.000 description 3
- 238000005457 optimization Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000011156 evaluation Methods 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 239000002245 particle Substances 0.000 description 2
- 238000007405 data analysis Methods 0.000 description 1
- 238000007418 data mining Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 239000004576 sand Substances 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/3331—Query processing
- G06F16/334—Query execution
- G06F16/3344—Query execution using natural language analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/335—Filtering based on additional data, e.g. user or group profiles
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/289—Phrasal analysis, e.g. finite state techniques or chunking
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Computational Linguistics (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Artificial Intelligence (AREA)
- Health & Medical Sciences (AREA)
- Audiology, Speech & Language Pathology (AREA)
- General Health & Medical Sciences (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开一种基于改进Apriori算法的水利工程安全隐患描述关联规则挖掘方法,首先使用Jieba分词对大量不同类别的水利工程安全隐患描述文本进行预处理,采用TextRank算法对分词结果进行关键词提取和词性筛选,得到隐患描述文本关键词;然后基于独热编码对关键词项集进行布尔矩阵转换,融合改进Apriori关联规则,挖掘各类隐患中的频繁项集,进行关联规则分析;最后以置信度为评价值,挖掘隐患描述之间的强关联关系,预测隐患产生趋势。本发明针对大量非结构化隐患描述进行数据预处理,改进传统Apriori算法,提高运算效率,能及时分析水利工程安全隐患描述,有助于水利工程安全隐患的预测及排查治理。
The invention discloses an association rule mining method for the description of potential safety hazards of water conservancy projects based on an improved Apriori algorithm. First, Jieba word segmentation is used to preprocess a large number of texts describing potential safety hazards of water conservancy projects of different categories, and the TextRank algorithm is used to extract keywords and analyze the results of word segmentation. Part-of-speech screening to obtain the keywords of the hidden danger description text; then based on the one-hot encoding, the keyword itemset is transformed into a Boolean matrix, the Apriori association rules are integrated and improved, the frequent itemsets in various hidden dangers are mined, and the association rules are analyzed; finally, the confidence level is used. In order to evaluate the value, the strong correlation between the descriptions of hidden dangers is mined, and the trend of hidden dangers is predicted. The invention performs data preprocessing for a large number of unstructured hidden danger descriptions, improves the traditional Apriori algorithm, improves the computing efficiency, can timely analyze the description of the hidden dangers of water conservancy projects, and is helpful for the prediction, investigation and management of hidden dangers of water conservancy projects.
Description
技术领域technical field
本发明涉及水利工程安全隐患排查技术领域,具体涉及一种基于改进Apriori算法的水利工程安全隐患描述关联规则挖掘方法。The invention relates to the technical field of investigation of potential safety hazards in water conservancy projects, in particular to a mining method for association rules for the description of potential safety hazards in water conservancy projects based on an improved Apriori algorithm.
背景技术Background technique
水利工程点多面广,存在大量的安全隐患,隐患之间常常存在关联性,挖掘各类安全隐患之间的关联关系具有重要意义。Apriori算法作为最经典的关联规则挖掘算法,在水利工程领域中已有相关应用。但传统的Apriori算法对于较大的数据集存在效率较低、耗时长的技术问题,且对于安全隐患描述这类非结构化文本难以进行准确分析。Water conservancy projects are multi-faceted and wide-ranging, and there are a large number of hidden dangers. There is often correlation between hidden dangers. It is of great significance to explore the correlation between various safety hazards. As the most classic association rule mining algorithm, Apriori algorithm has been applied in the field of hydraulic engineering. However, the traditional Apriori algorithm has technical problems of low efficiency and time-consuming for large data sets, and it is difficult to accurately analyze unstructured texts such as descriptions of security risks.
为了解决上述存在的问题,如黄黎明等在《基于关联规则的水利工程建设质量安全监管数据挖掘与分析》中,根据问题描述将工程所存在技术问题划分为50个问题类别,采用Apriori算法对工程属性与问题描述进行关联规则挖掘,该方法对原始隐患数据进行了合并归类的预处理,实现了隐患描述的结构化表达,但该方法处理原始隐患数据需要进行人工操作,对于大量数据需要耗费大量时间,且具有一定的主观性,影响结果的准确性;又如陈述等在《水电工程施工安全隐患关联规则挖掘》中,提出基于短语提取的关联规则优化算法,基于短语提取技术对隐患文本进行关键短语提取,同时将短语度量值作为评价指标,优化Apriori算法中的支持度,从而挖掘隐患属性之间的关联规则,该方法通过短语提取技术挖掘文本中的新词,提高了分词质量,同时重新定义支持度,使得关联规则挖掘更加科学,但该方法采取的短语提取技术,所需的规则库搭建及维护需要大量人工成本,挖掘出的新词与水利工程领域的专有名词存在一定偏差,同时存在无明确含义的分词结果,如易造成,未设置等,且在Apriori算法迭代方面没有进行改进,运算效率较低。In order to solve the above problems, for example, Huang Liming et al. in "Data Mining and Analysis of Water Conservancy Project Construction Quality and Safety Supervision Based on Association Rules", according to the problem description, the technical problems existing in the project are divided into 50 problem categories, and the Apriori algorithm is used to analyze the problems. Engineering attributes and problem descriptions are used for association rule mining. This method preprocesses the original hidden danger data by merging and classifying them, and realizes the structured expression of the hidden danger description. It consumes a lot of time, and has a certain degree of subjectivity, which affects the accuracy of the results; another example is the statement in "Association Rule Mining of Hidden Safety Hazards in Hydropower Engineering Construction", which proposes an optimization algorithm for association rules based on phrase extraction, based on phrase extraction technology. The text is extracted for key phrases, and the phrase measurement value is used as the evaluation index to optimize the support in the Apriori algorithm, so as to mine the association rules between hidden attributes. This method uses phrase extraction technology to mine new words in the text and improve the quality of word segmentation. , at the same time redefine the support degree to make association rule mining more scientific, but the phrase extraction technology adopted by this method requires a lot of labor costs to build and maintain the required rule base, and the new words excavated and the proper nouns in the field of water conservancy engineering exist There is a certain deviation, and there are word segmentation results with no clear meaning, such as easy to cause, not set, etc., and there is no improvement in the iteration of the Apriori algorithm, and the operation efficiency is low.
因此,构建一种高效的水利工程安全隐患描述关联规则挖掘方法是必要的,本发明所构建的一种基于改进Apriori算法的水利工程安全隐患描述关联规则挖掘方法,与现有方法相比,具有两个显著特征:(1)构建水利工程领域自定义词库对隐患文本进行分词,采用TextRank算法进行词性筛选及关键词提取,并基于独热编码将分词结果转换为布尔矩阵,预处理后的隐患文本只保留了一些重要关键词。(2)优化Apriori算法,在逐层迭代之前,对布尔矩阵先进行一次频繁项集筛选。在迭代中进行剪枝优化,同时动态缩小数据集,关联规则挖掘运算效率明显得到了提高。Therefore, it is necessary to construct an efficient mining method of association rules for the description of potential safety hazards in water conservancy projects. Compared with the existing method, the method for mining association rules for the description of potential safety hazards in water conservancy projects constructed in the present invention based on the improved Apriori algorithm has the advantages of Two notable features: (1) Constructing a custom thesaurus in the field of hydraulic engineering to segment hidden texts, using TextRank algorithm for part-of-speech screening and keyword extraction, and converting the segmentation results into Boolean matrices based on one-hot encoding. The hidden text only retains some important keywords. (2) Optimize the Apriori algorithm. Before iterating layer by layer, perform a frequent itemset screening on the Boolean matrix. The pruning optimization is carried out in the iteration, and the data set is dynamically reduced at the same time, and the operation efficiency of association rule mining has been significantly improved.
发明内容SUMMARY OF THE INVENTION
本发明目的在于提出一种基于改进Apriori算法的水利工程安全隐患描述关联规则挖掘方法,解决水利工程安全施工中隐患描述难以结构化表达及关联规则挖掘算法运算效率低下的问题,及时挖掘水利工程施工中安全隐患之间的关联规则,为水利工程安全隐患的预测及排查治理提供辅助支持。The purpose of the present invention is to propose an association rule mining method based on the improved Apriori algorithm for the description of potential safety hazards in water conservancy projects, so as to solve the problems of difficulty in structurally expressing the description of hidden dangers in the safety construction of water conservancy projects and the low computing efficiency of the association rule mining algorithm, so as to excavate the construction of water conservancy projects in time. The association rules between hidden safety hazards in the water conservancy project provide auxiliary support for the prediction, investigation and management of safety hazards in water conservancy projects.
本发明的一种基于改进Apriori算法的水利工程安全隐患描述关联规则挖掘方法,包括以下步骤:A method for mining association rules for the description of potential safety hazards in water conservancy projects based on the improved Apriori algorithm of the present invention includes the following steps:
步骤S1,构建水利工程领域自定义词库,采用jieba分词对隐患数据集进行分词、去停用词,通过TextRank算法筛选词性,提取出的关键词作为输入数据集;Step S1, constructing a custom thesaurus in the field of water conservancy engineering, using jieba word segmentation to segment the hidden danger data set, removing stop words, filtering parts of speech through the TextRank algorithm, and using the extracted keywords as the input data set;
步骤S2,步骤S2,基于独热one-hot编码对步骤S1得到的输入数据集进行布尔矩阵转换;Step S2, step S2, based on one-hot one-hot encoding, the input data set obtained in step S1 is subjected to Boolean matrix conversion;
步骤S3,通过改进Apriori算法计算各项集支持度,筛选出不小于最小支持度的项集,即为频繁项集;In step S3, the support degree of each item set is calculated by improving the Apriori algorithm, and the itemsets that are not less than the minimum support degree are screened out, which are frequent itemsets;
步骤S4,对得到的频繁项集进行置信度计算,筛选出不小于最小置信度的关联规则,即为强关联规则A=>B,即项集A出现的情况下,项集B也会尽可能出现。Step S4, perform confidence calculation on the obtained frequent itemsets, and filter out the association rules not less than the minimum confidence, that is, strong association rules A=>B, that is, when itemset A appears, itemset B will also be exhausted. may appear.
优选地,所述步骤S1具体包括:Preferably, the step S1 specifically includes:
步骤S11,搜集水利工程领域词条,构建水利工程领域自定义词库,采用jieba分词,对隐患数据集进行分词,并标注词性;Step S11, collecting entries in the field of water conservancy engineering, constructing a custom thesaurus in the field of water conservancy engineering, using jieba word segmentation, segmenting the hidden danger data set, and marking the part of speech;
步骤S12,载入停用词库,剔除分词结果中的语气助词、副词、介词、连接词等通常自身并无明确意义的词;Step S12, load the stop word database, and remove words that usually have no clear meaning themselves, such as modal particles, adverbs, prepositions, conjunctions, etc. in the word segmentation result;
步骤S13,采用TextRank算法,对分词重要性进行排序,然后提取分词中词性为名词、动词、动名词、地名的关键词,作为最终的输入数据集。Step S13, using the TextRank algorithm to sort the importance of word segmentation, and then extracting keywords whose parts of speech are nouns, verbs, gerunds, and place names in the word segmentation, as the final input data set.
经过上述步骤S11-S13,对数据集中难以结构化表达的隐患描述文本进行了预处理。After the above steps S11-S13, the hidden danger description texts that are difficult to be expressed in a structured way in the data set are preprocessed.
优选地,所述步骤S2具体包括:Preferably, the step S2 specifically includes:
步骤S21,首先将输入数据集D={D1,D1…,Dn},转化为DataFrame数据框形式的矩阵T,矩阵T的形式为:Step S21, first convert the input data set D={D 1 , D 1 . . . , D n } into a matrix T in the form of a DataFrame data frame, and the form of the matrix T is:
其中,n为隐患描述数据数量,m为n条数据中最多的分词数量,Tij为第i条数据的第j个关键词,若为空则为Null;Di为数据集中的第i条数据,即集合{Ti1,Ti2,…,Tin};Among them, n is the number of hidden danger description data, m is the maximum number of word segmentations in the n data, T ij is the j-th keyword of the i-th data, if it is empty, it is Null; D i is the i-th item in the data set data, that is, the set {T i1 ,T i2 ,...,T in };
步骤S22,对数据框矩阵T进行独热one-hot编码,转换成布尔矩阵M;设I={I1,I2,…,It}为数据集D中所有不同的项组成的集合,布尔矩阵M的形式为:Step S22, perform one-hot one-hot encoding on the data frame matrix T, and convert it into a Boolean matrix M; let I={I 1 , I 2 ,...,I t } be the set composed of all different items in the data set D, The Boolean matrix M has the form:
其中,t为数据集D中所有不同的关键词的数量,Mij为第i条数据对于第j个关键词的布尔值,若Di包含Ij,即第i条数据包含第j个关键词,则Mij的值为1(True),否则为0(False)。Among them, t is the number of all different keywords in the data set D, M ij is the Boolean value of the i-th data for the j-th keyword, if D i contains I j , that is, the i-th data contains the j-th key word, the value of Mij is 1 (True), otherwise it is 0 (False).
通过步骤S2将经步骤S1预处理的中文文本转换为容易识别的布尔矩阵。The Chinese text preprocessed by step S1 is converted into an easily recognizable Boolean matrix through step S2.
优选地,所述步骤S3具体包括:Preferably, the step S3 specifically includes:
步骤S31,在进行迭代之前,对步骤S22转换得到的布尔矩阵,进行一次遍历,对布尔矩阵中的每一列分别进行计数求和,快速挖掘1维频繁项集,删除非频繁项集;Step S31, before performing the iteration, perform a traversal on the Boolean matrix converted in step S22, count and sum up each column in the Boolean matrix, quickly mine 1-dimensional frequent itemsets, and delete non-frequent itemsets;
步骤S32,在进行迭代时,k-1维频繁项集集合Lk-1连接形成k维候选项集集合,记作Ck;设I1和I2是Lk-1中的项集,若他们中有k-2个项相同,则I1、I2可连接产生结果项集,该结果项集为候选项集集合Ck之一;Step S32, during iteration, the k-1-dimensional frequent itemset set L k-1 is connected to form a k-dimensional candidate item set set, denoted as C k ; let I 1 and I 2 be the itemsets in L k-1 , If k-2 items in them are the same, then I 1 and I 2 can be connected to generate a result item set, which is one of the candidate item set sets C k ;
步骤S33,对候选项集集合Ck进行剪枝,Ck为Lk的超集;对于Lk-1中的每个项集T,依次遍历Ck中的所有候选项集,并基于布尔矩阵对每个候选项集进行计数。遍历全部结束后,通过计数结果对Ck中的每个候选项集进行裁剪,若计数小于k则删除该候选项集,同时删除数据集中所有包含该项集的项集;否则保留并进行下一步;Step S33, prune the candidate item set C k , where C k is a superset of L k ; for each item set T in L k-1 , traverse all the candidate item sets in C k in turn, and based on Boolean The matrix counts each candidate item set. After the traversal is complete, trim each candidate item set in C k according to the count result. If the count is less than k, delete the candidate item set, and delete all itemsets that contain the item set in the dataset; otherwise, keep it and proceed to the next step. step;
步S34,对剪枝后的每个候选项集进行支持度计算,支持度(support)公式为:Step S34, calculate the support degree for each candidate item set after pruning, and the support degree (support) formula is:
support(A=>B)=P(A∪B)support(A=>B)=P(A∪B)
式中:A、B为I中任意项组成的项集,即表示数据包含项集A和B中的每个项的概率;In the formula: A and B are the itemsets composed of any items in I, that is, the probability that the data contains each item in the itemsets A and B;
若候选项集支持度不小于最小支持度,则为k-频繁项集,并加入Lk,否则删除该项集,同时删除数据集中所有包含该项集的项集。筛选完后返回步骤S32,直至找不到k-频繁项集。If the support degree of the candidate item set is not less than the minimum support degree, it is a k-frequent itemset, and is added to L k , otherwise, the item set is deleted, and all itemsets containing this item set are deleted in the data set at the same time. After screening, go back to step S32 until no k-frequent itemsets are found.
通过步骤2和S31,在迭代之前,无需对各个关键词进行支持度计算,直接对布尔矩阵中的每一列分别进行计数求和,快速挖掘1维频繁项集,删除非频繁项集;基于布尔矩阵对大量的数据集进行快速筛选,从而大大缩小数据集,提高了迭代初期庞大数据集情况下的迭代运算效率。在进行迭代时,k-1维频繁项集集合Lk-1连接形成k维候选项集集合Ck,对于Lk-1中的每个项集T,依次遍历Ck中的所有候选项集,并基于布尔矩阵对每个候选项集进行计数。遍历全部结束后,通过计数结果对Ck中的每个候选项集进行裁剪,若计数小于k则删除该候选项集,同时删除数据集中所有包含该项集的项集。通过步骤S32优化剪枝环节,将时间复杂度从O(n2)降到O(n),提高了整体的迭代运算效率。Through steps 2 and S31, before the iteration, there is no need to calculate the support degree of each keyword, directly count and sum each column in the Boolean matrix, quickly mine 1-dimensional frequent itemsets, and delete non-frequent itemsets; based on Boolean The matrix can quickly filter a large number of data sets, thereby greatly reducing the data set, and improving the iterative operation efficiency in the case of a huge data set in the early stage of iteration. During iteration, the k-1-dimensional frequent itemset set L k-1 is connected to form a k-dimensional candidate item set C k , and for each item set T in L k-1 , all candidate items in C k are traversed in turn sets and counts each candidate item set based on a Boolean matrix. After the traversal is completed, each candidate item set in C k is trimmed through the counting result. If the count is less than k, the candidate item set is deleted, and all itemsets containing this item set are deleted in the dataset at the same time. By optimizing the pruning link in step S32, the time complexity is reduced from O(n 2 ) to O(n), and the overall iterative operation efficiency is improved.
传统的Apriori算法,对于每一个候选项集的k-1维子集,均要重新搜索一遍Lk-1,这增加了运算时间,影响了算法效率。改进的Apriori算法,主要在于迭代之前,先进行快速挖掘频繁项集,在迭代中进行剪枝优化,同时动态缩小数据集,从而显著提高算法的运算效率。In the traditional Apriori algorithm, for each k-1 dimensional subset of the candidate item set, L k-1 needs to be searched again, which increases the operation time and affects the algorithm efficiency. The improved Apriori algorithm mainly lies in the rapid mining of frequent itemsets before the iteration, pruning and optimization in the iteration, and the dynamic reduction of the data set at the same time, thereby significantly improving the computational efficiency of the algorithm.
与现有技术相比,本发明的有益效果在于:Compared with the prior art, the beneficial effects of the present invention are:
(1)本发明通过构建水利工程领域自定义词库,采用TextRank算法进行关键词提取和词性过滤,通过机器自动分词,实现了对于难以结构化表达的隐患描述文本的预处理,克服了现有技术中人工成本高及无法识别水利工程领域性术语的问题。(1) In the present invention, by constructing a custom thesaurus in the field of water conservancy engineering, using the TextRank algorithm for keyword extraction and part-of-speech filtering, and through automatic word segmentation by machines, the preprocessing of the hidden danger description text that is difficult to structurally express is realized, and the existing The problems of high labor cost and inability to recognize the terminology of hydraulic engineering in the technology.
(2)本发明在迭代之前,基于布尔矩阵对大量的数据集进行快速筛选,从而大大缩小数据集,提高了迭代初期庞大数据集情况下的迭代运算效率;在迭代时,通过优化剪枝环节,将时间复杂度从O(n2)降到O(n),提高了整体的迭代运算效率。(2) Before the iteration, the present invention quickly screens a large number of data sets based on the Boolean matrix, thereby greatly reducing the data set and improving the iterative operation efficiency in the case of a huge data set in the early iteration; , which reduces the time complexity from O(n 2 ) to O(n) and improves the overall iterative operation efficiency.
(3)本发明通过改进迭代前和迭代时的算法,大大提升了Apriori算法的运算效率,克服了前述现有技术中庞大数据集情况下算法运算效率较低的问题。(3) The present invention greatly improves the operation efficiency of the Apriori algorithm by improving the algorithms before and during iteration, and overcomes the problem of low algorithm operation efficiency in the case of huge data sets in the prior art.
附图说明Description of drawings
图1为本发明的整体工作流程图。Fig. 1 is the overall working flow chart of the present invention.
具体实施方式Detailed ways
下面结合实施例对本发明技术方案进行详细说明,但是本发明的保护范围不局限于所述实施例。The technical solutions of the present invention will be described in detail below with reference to the embodiments, but the protection scope of the present invention is not limited to the embodiments.
实施例1Example 1
如图1所示,本发明所述方法具体包括以下步骤:As shown in Figure 1, the method of the present invention specifically comprises the following steps:
步骤S1,构建水利工程领域自定义词库,采用jieba分词对隐患数据集进行分词、去停用词,通过TextRank算法筛选词性,提取出的关键词作为输入数据集,具体步骤为:Step S1, construct a custom thesaurus in the field of water conservancy engineering, use jieba word segmentation to segment the hidden danger data set, remove stop words, filter the parts of speech through the TextRank algorithm, and use the extracted keywords as the input data set. The specific steps are:
步骤S11,搜集水利工程隐患描述语句1917条作为样本数据集,部分样本数据集样本数据如表1所示,搜集水利工程领域词条7480条,构建水利工程领域自定义词库,采用jieba分词,对样本数据进行分词,并标注词性。Step S11, collect 1917 water conservancy project hidden danger description sentences as a sample data set, some of the sample data set sample data are shown in Table 1, collect 7480 water conservancy engineering field entries, build a custom thesaurus in the water conservancy engineering field, use jieba word segmentation, Segment the sample data and mark the part of speech.
部分词条如:暗灯、按地电阻值、暗敷、暗管、暗涵、暗合页、暗间、暗梁、暗炉片、安全出口、安全出口灯、安全出口灯出线口、安全岛、安全阀门调试记录、安全防范设施、安全管理、安全接地、安全警报系统等。Some entries such as: dark light, ground resistance value, dark application, dark pipe, dark culvert, dark hinge, dark room, dark beam, dark furnace piece, safety exit, safety exit light, safety exit light outlet, safety island, Safety valve debugging records, safety precautions, safety management, safety grounding, safety alarm system, etc.
表1Table 1
步骤S12,载入停用词库,剔除分词结果中的语气助词、副词、介词、连接词等通常自身并无明确意义的词,如“@”、“阿”、“而且”、“与”等。Step S12, load the stop word database, and remove the modal particles, adverbs, prepositions, conjunctions and other words that usually have no clear meaning in the word segmentation result, such as "@", "A", "and", "and" Wait.
步骤S13,采用TextRank算法,对分词重要性进行排序,提取分词中词性为名词(n)、动词(v)、动名词(vn)、地名(ns)的关键词。Step S13, using the TextRank algorithm to sort the importance of word segmentation, and extracting keywords whose parts of speech are noun (n), verb (v), gerund (vn), and place name (ns) in the word segmentation.
经步骤S11-S13得到如表2所示的最终的分词结果作为输入数据集。After steps S11-S13, the final word segmentation results shown in Table 2 are obtained as the input data set.
表2分词结果Table 2 word segmentation results
步骤S2,对步骤S1得到的输入数据集进行布尔矩阵编码,即对于每条数据,若包含数据集中对应项集,则标记为1(True),否则为0(False),具体步骤为:In step S2, the Boolean matrix encoding is performed on the input data set obtained in step S1, that is, for each piece of data, if it contains the corresponding item set in the data set, it is marked as 1 (True), otherwise it is 0 (False). The specific steps are:
步骤S21,首先将输入数据集转化为DataFrame数据框形式的1917*20矩阵,其中,行数为1917,即隐患描述数据数量,列数为20,即1917条数据中最多的分词数量,第i行第j列个词语即为第i条数据的第j个关键词,若为空则为Null,DataFrame数据框如表3所示。Step S21, first convert the input data set into a 1917*20 matrix in the form of a DataFrame data frame, wherein the number of rows is 1917, that is, the number of hidden danger description data, and the number of columns is 20, that is, the maximum number of word segmentations in the 1917 pieces of data, the i-th The word in the jth column of the row is the jth keyword of the ith data. If it is empty, it is Null. The DataFrame data frame is shown in Table 3.
表3DataFrame数据框Table 3DataFrame data frame
步骤S22,对DataFrame数据框进行独热one-hot编码,转换成布尔矩阵,矩阵为1917*1139,其中,行数为1917,即隐患描述数据数量,列数为1139,即数据集中所有不同的关键词的数量,若i条数据包含第j个关键词,则第i行第j列的值为1(True),否则为0(False)。编码后的布尔矩阵如表4所示。Step S22, perform one-hot encoding on the DataFrame data frame, and convert it into a Boolean matrix, the matrix is 1917*1139, wherein the number of rows is 1917, that is, the number of hidden danger description data, and the number of columns is 1139, that is, all different data in the data set. The number of keywords. If the i data contains the jth keyword, the value of the ith row and the jth column is 1 (True), otherwise it is 0 (False). The encoded Boolean matrix is shown in Table 4.
表4布尔矩阵结果Table 4 Boolean matrix results
步骤S3,通过改进Apriori算法计算各项集支持度,筛选出不小于最小支持度的项集即为频繁项集,由于数据量高达1917条,本实施例最小支持度阈值设置为0.01。筛选长度大于等于3的频繁项集,结果如表5所示。In step S3, the item set support is calculated by improving the Apriori algorithm, and the itemsets that are not less than the minimum support are selected as frequent itemsets. Since the data volume is as high as 1917, the minimum support threshold in this embodiment is set to 0.01. The frequent itemsets whose length is greater than or equal to 3 are filtered, and the results are shown in Table 5.
表5频繁项集结果Table 5 Results of frequent itemsets
通过频繁项集结果反映,在该数据集所对应的水利工程安全施工过程中,拌和站检修车间、砂石加工厂配电室等地点经常出现安全隐患,脚手架密目网脱落、电缆绝缘老化、施工现场人员佩戴等安全隐患问题较为频繁出现。According to the results of frequent itemsets, during the safety construction process of the water conservancy project corresponding to this data set, there are often hidden safety hazards in the maintenance workshop of the mixing station, the power distribution room of the sand and gravel processing plant, etc. Safety hazards such as wearing by construction site personnel occur frequently.
步骤S4,对得到的频繁项集进行置信度计算,筛选出不小于最小置信度的关联规则,即为强关联规则。使用association_rules()函数对步骤S3得到的频繁项集进行进一步关联规则挖掘,以置信度为评价值进行挖掘。设置最低置信度为0.8。强关联规则结果如表6所示。置信度为1则为绝对关联项。In step S4, a confidence level is calculated on the obtained frequent itemsets, and an association rule not less than the minimum confidence level is screened out, which is a strong association rule. Use the association_rules() function to perform further association rule mining on the frequent itemsets obtained in step S3, and perform mining with confidence as the evaluation value. Set the minimum confidence level to 0.8. The results of strong association rules are shown in Table 6. A confidence level of 1 is an absolute correlation item.
表6强关联规则结果Table 6 Results of strong association rules
通过强关联规则结果反映,在该数据集所对应的水利工程安全施工过程中,脚手架密目网经常出现脱落的安全隐患问题,施工现场的人员经常出现佩戴相关问题,拌合站检修车间是安全隐患较为频繁发生的地方。The results of the strong association rule reflect that during the safe construction of the water conservancy project corresponding to this dataset, the scaffolding mesh net often falls off, and the personnel at the construction site often have problems with wearing it. The maintenance workshop of the mixing station is safe A place where hidden dangers occur more frequently.
在本实施例中,本发明的有益效果具体体现在:(1)对于本实施例采用的1917条数据,通过机器代码实现自动分词,分词结果如表2所示,而前述的现有技术中的短语提取技术由于未引入水利工程领域自定义词库,且未进行词性过滤,产生了如”易造成”、”未要求”、”未设置”等没有明确含义和词性的词语,降低了分词质量,影响关联规则挖掘的准确性。(2)基于本实施例采用的1917条数据,通过PyCharm进行代码测试,传统的Apriori算法需要花费0.1587965秒,而本发明中提出的改进Apriori算法只需要花费0.0328939秒,大大提升了算法的运算效率。In this embodiment, the beneficial effects of the present invention are embodied in: (1) for the 1917 pieces of data used in this embodiment, automatic word segmentation is realized through machine codes, and the word segmentation results are shown in Table 2, while in the aforementioned prior art Since the phrase extraction technology of the company did not introduce a custom thesaurus in the field of water conservancy engineering and did not perform part-of-speech filtering, words with no clear meaning and part of speech such as "easy to cause", "not required", and "not set" were generated, which reduced the number of word segmentations. quality, which affects the accuracy of association rule mining. (2) Based on the 1917 pieces of data used in this embodiment, code testing is performed through PyCharm. The traditional Apriori algorithm takes 0.1587965 seconds, while the improved Apriori algorithm proposed in the present invention only takes 0.0328939 seconds, which greatly improves the operational efficiency of the algorithm .
Claims (4)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210471547.4A CN114756656A (en) | 2022-04-29 | 2022-04-29 | Mining method of association rules for hydraulic engineering safety hazard description based on improved Apriori algorithm |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210471547.4A CN114756656A (en) | 2022-04-29 | 2022-04-29 | Mining method of association rules for hydraulic engineering safety hazard description based on improved Apriori algorithm |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114756656A true CN114756656A (en) | 2022-07-15 |
Family
ID=82333842
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210471547.4A Pending CN114756656A (en) | 2022-04-29 | 2022-04-29 | Mining method of association rules for hydraulic engineering safety hazard description based on improved Apriori algorithm |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114756656A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115794801A (en) * | 2022-12-23 | 2023-03-14 | 东南大学 | Data analysis method for mining chain relation of automatic driving accident cause |
CN117314154A (en) * | 2023-09-14 | 2023-12-29 | 甘肃电通电力工程设计咨询有限公司 | Construction site intelligent monitoring system and method based on Beidou positioning |
CN118013955A (en) * | 2024-04-08 | 2024-05-10 | 中国标准化研究院 | A standard information updating method based on association algorithm |
CN118427181A (en) * | 2024-04-03 | 2024-08-02 | 云启智慧科技有限公司 | A data governance system for developing data standards based on knowledge management |
-
2022
- 2022-04-29 CN CN202210471547.4A patent/CN114756656A/en active Pending
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115794801A (en) * | 2022-12-23 | 2023-03-14 | 东南大学 | Data analysis method for mining chain relation of automatic driving accident cause |
CN115794801B (en) * | 2022-12-23 | 2023-08-15 | 东南大学 | Data analysis method for mining cause chain relation of automatic driving accidents |
CN117314154A (en) * | 2023-09-14 | 2023-12-29 | 甘肃电通电力工程设计咨询有限公司 | Construction site intelligent monitoring system and method based on Beidou positioning |
CN117314154B (en) * | 2023-09-14 | 2024-06-04 | 甘肃电通电力工程设计咨询有限公司 | Construction site intelligent monitoring system and method based on Beidou positioning |
CN118427181A (en) * | 2024-04-03 | 2024-08-02 | 云启智慧科技有限公司 | A data governance system for developing data standards based on knowledge management |
CN118013955A (en) * | 2024-04-08 | 2024-05-10 | 中国标准化研究院 | A standard information updating method based on association algorithm |
CN118013955B (en) * | 2024-04-08 | 2024-07-26 | 中国标准化研究院 | Standard information updating method based on association algorithm |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114756656A (en) | Mining method of association rules for hydraulic engineering safety hazard description based on improved Apriori algorithm | |
CN106649260B (en) | Product characteristic structure tree construction method based on comment text mining | |
CN109543178B (en) | Method and system for constructing judicial text labeling system | |
CN108573045B (en) | Comparison matrix similarity retrieval method based on multi-order fingerprints | |
US6665661B1 (en) | System and method for use in text analysis of documents and records | |
CN112199938B (en) | A scientific and technological project similarity analysis method, computer equipment, and storage medium | |
CN104182527B (en) | Association rule mining method and its system between Sino-British text word based on partial order item collection | |
CN101710343A (en) | Body automatic build system and method based on text mining | |
CN103049532A (en) | Knowledge base engine construction and query method based on emergency management of emergencies | |
CN116245107B (en) | Power audit text entity recognition method, device, equipment and storage medium | |
CN114912435A (en) | Method and device for power text knowledge discovery based on frequent itemset algorithm | |
CN111429184A (en) | User portrait extraction method based on text information | |
CN114817556B (en) | A knowledge graph construction method for substation project site selection | |
CN111857688A (en) | SQL code automatic completion method, system and storage medium | |
CN115545671A (en) | Method and system for structured processing of laws and regulations | |
CN114266256A (en) | A method and system for extracting new words in the field | |
CN115794798A (en) | Market supervision informationized standard management and dynamic maintenance system and method | |
CN118171204A (en) | Method and system for classifying risk levels of potential safety hazards of electric power based on knowledge graph | |
CN112488593A (en) | Auxiliary bid evaluation system and method for bidding | |
CN117827882B (en) | Deep learning-based financial database SQL quality scoring method, system, equipment and storable medium | |
CN110928985A (en) | Scientific and technological project duplicate checking method for automatically extracting near-meaning words based on deep learning algorithm | |
CN117973382A (en) | Method, system, equipment and medium for constructing digital industrial production accident case library | |
CN114722159B (en) | Multi-source heterogeneous data processing method and system for numerical control machine tool manufacturing resources | |
CN116861905A (en) | Deep learning-based power standard entity relation extraction method and device | |
CN110245275A (en) | A kind of extensive similar quick method for normalizing of headline |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |