Sequence pattern mining method and device and readable storage medium
By calculating the weight and comprehensive evaluation indicators of the sequence mode, the problem of insufficient mode frequency in the existing technology is solved, more accurate sequence mode mining is achieved, and more valuable decision-making basis is provided.
Patent Information
- Application Number
- CN202411610258.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-03-04
AI Technical Summary
The existing sequence mode mining methods mainly focus on the frequency of the mode and cannot fully reflect the authenticity of the mode.
The importance of the mode is determined by calculating the sequence bitmap and position bitmap of each 1-mode, and calculating high-weight frequent modes based on the weight of the sequence, combining support, weighted support and comprehensive evaluation indicators.
It can more accurately reflect the relative importance between sequence patterns, improve the accuracy and practicality of pattern mining, and provide a more reliable decision-making basis.
Smart Images

Figure CN119557353A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data mining technology, and in particular to a sequence pattern mining method, device and readable storage medium. Background Art
[0002] In today's data-driven world, it is becoming increasingly important to extract valuable information and knowledge from large-scale complex data. Sequential pattern mining is a key research direction in the field of data mining, which is dedicated to discovering frequently occurring patterns or regularities from sequence data. These patterns can reveal hidden correlations in the data and provide important basis for decision support and predictive analysis.
[0003] Sequence data is widely present in various fields, such as user behavior analysis, bioinformatics, financial transactions, network security, etc. Traditional sequence pattern mining algorithms mainly focus on the frequency of patterns, that is, the number of times the pattern appears in the data set. However, considering only the frequency is often not enough to reflect the true importance of the pattern. In practical applications, the inventors found that different sequences or patterns may have different weights or importance. Introducing weight factors into sequence pattern mining has become an important research direction. Weights can reflect the importance, influence or value of a sequence or pattern. For example, in e-commerce, the purchasing behavior of high-value users may be more meaningful than that of ordinary users.
[0004] Existing sequential pattern mining technologies mainly include:
[0005] Apriori algorithm and its variants: methods based on candidate set generation and testing.
[0006] FP-growth algorithm: uses FP tree structure for frequent pattern mining.
[0007] PrefixSpan algorithm: A projection-based sequential pattern growth method.
[0008] SPADE algorithm: Fast pattern mining using vertical data formats.
[0009] However, although these algorithms have their own advantages in different application scenarios, most of them still focus on the frequency of patterns without fully considering the weights. Therefore, these algorithms cannot fully reflect the true importance of patterns. Summary of the invention
[0010] The technical problem to be solved by the present invention is to provide a sequence pattern mining method, device and readable storage medium in response to the above-mentioned shortcomings of the prior art, so as to solve the problem that the existing sequence pattern mining methods mainly focus on the frequency of the pattern and cannot fully reflect the true importance of the pattern.
[0011] In a first aspect, the present invention provides a sequential pattern mining method, the method comprising:
[0012] S1, calculate the sequence bitmap and position bitmap of each 1-pattern binary based on the sequence database;
[0013] S2, calculating a high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database;
[0014] S3, initialize k=2;
[0015] S4, generating sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns;
[0016] S5, calculating a high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database;
[0017] S6, determining whether k is equal to a preset mode threshold, if so, ending the process, if not, increasing k by 1 and returning to step S4;
[0018] The sequence bitmap indicates the specific position of each element in the pattern in the sequence containing the pattern, and the position bitmap indicates the specific position of each item in the pattern in the sequence containing the pattern.
[0019] Furthermore, the step of calculating the high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database specifically includes:
[0020] Calculate the support of each 1-pattern according to the number of values 1 stored in the sequence bitmap of each 1-pattern;
[0021] For each sequence whose value is 1 in the sequence bitmap of each 1-pattern, the weights corresponding to the corresponding sequences are accumulated and divided by the total weight of the sequence database to obtain the weighted support of each 1-pattern;
[0022] Calculating a comprehensive evaluation index according to the support and weighted support of each of the 1-patterns;
[0023] The 1-pattern whose support is greater than or equal to a preset minimum support threshold, whose weighted support is greater than or equal to a preset minimum weight support threshold, and whose comprehensive evaluation index is greater than or equal to a preset minimum comprehensive score threshold is determined as a high-weight frequent 1-pattern.
[0024] Further, the generating of sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns specifically includes:
[0025] Perform bitwise AND operation on the sequence bitmaps of any two high-weight frequent (k-1)-patterns among all high-weight frequent (k-1)-patterns to obtain the sequence bitmaps of all k-patterns;
[0026] For each sequence whose value is 1 in the sequence bitmap of each of the k-patterns, obtain the position bitmaps of the sequences of two high-weight frequent (k-1)-patterns constituting the k-pattern, perform a bitwise OR operation on the two position bitmaps, and for each sequence whose value is 0 in the sequence bitmap of each of the k-patterns, set the corresponding position bitmap to 0, thereby obtaining the position bitmaps of all k-patterns.
[0027] Further, the high-weight frequent k-pattern is obtained according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database, specifically including:
[0028] Calculate the support of each k-pattern according to the number of values 1 stored in the sequence bitmap of each k-pattern;
[0029] For each sequence whose value is 1 in the sequence bitmap of each k-pattern, the weights corresponding to the corresponding sequences are accumulated and divided by the total weight of the sequence database to obtain the weighted support of each k-pattern;
[0030] Calculating a comprehensive evaluation index according to the support and weighted support of each of the k-patterns;
[0031] The k-pattern whose support is greater than or equal to a preset minimum support threshold, whose weighted support is greater than or equal to a preset minimum weight support threshold, and whose comprehensive evaluation index is greater than or equal to a preset minimum comprehensive score threshold is determined as a high-weight frequent k-pattern.
[0032] Furthermore, the comprehensive evaluation index is calculated according to the following formula:
[0033] score(k)=α*sup(k)+(1-α)*weiSup(k)
[0034] Where score(k) is the comprehensive evaluation index of the k-mode, α is a predefined parameter used to adjust the relative importance of support and weighted support, α∈[0,1], sup(k) is the support of the k-mode, and weiSup(k) is the weighted support of the k-mode.
[0035] Furthermore, the method further comprises:
[0036] Create a corresponding frequent item object according to each high-weight frequent 1-pattern and add it to the pre-established high-weight frequent pattern set;
[0037] Creating a corresponding frequent item object according to each high-weight frequent k-pattern, and adding it to the high-weight frequent pattern set;
[0038] Each frequent item object includes a pattern, support corresponding to the pattern, weighted support, comprehensive evaluation index, sequence bitmap and position bitmap.
[0039] Furthermore, after obtaining the high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database, the method further comprises:
[0040] For the high-weight frequent k-pattern, using the weighted support in the high-weight frequent pattern set, obtain the confidence of multiple sub-patterns from X to Y;
[0041] Constructing a weighted confidence matrix of the high-weight frequent k-pattern according to the confidences of the multiple sub-patterns from X to Y;
[0042] Strong association rules are identified based on the weight confidence matrix.
[0043] Furthermore, the confidence is calculated according to the following formula:
[0044] conf(X→Y)=weiSup(X∪Y) / weiSup(X)
[0045] Where conf(X→Y) represents the confidence from subpattern X to Y, weiSup(X∪Y) represents the weighted support of the union of subpatterns X and Y, weiSup(X) represents the weighted support of subpattern X, X and Y are non-empty subsequences of the high-weight frequent k-pattern, and
[0046] Furthermore, if conf(X→Y) is not less than a preset minimum confidence threshold, it means that X and Y are strongly associated.
[0047] In a second aspect, the present invention provides a sequential pattern mining device, the device comprising:
[0048] A first bitmap calculation module, used for calculating a sequence bitmap and a position bitmap of each 1-mode binary based on a sequence database;
[0049] A first frequent pattern acquisition module, connected to the first bitmap calculation module, is used to calculate and obtain a high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database;
[0050] an initialization module, connected to the first frequent pattern acquisition module, and used to initialize k=2;
[0051] A second bitmap calculation module, connected to the initialization module, is used to generate sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns;
[0052] A second frequent pattern acquisition module, connected to the second bitmap calculation module, is used to calculate and obtain a high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database;
[0053] an iterative judgment module, connected to the second frequent pattern acquisition module, for judging whether k is equal to a preset pattern threshold, if so, terminating the process, if not, increasing k by 1, returning to and executing the second bitmap calculation module;
[0054] The sequence bitmap indicates the specific position of each element in the pattern in the sequence containing the pattern, and the position bitmap indicates the specific position of each item in the pattern in the sequence containing the pattern.
[0055] In a third aspect, the present invention provides a sequential pattern mining device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement the sequential pattern mining method described in the first aspect.
[0056] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for mining sequential patterns described in the first aspect is implemented.
[0057] The present invention provides a method, device and readable storage medium for mining sequential patterns. First, the binary sequence bitmap and position bitmap of each 1-pattern are calculated based on a sequence database; and a high-weight frequent 1-pattern is obtained based on the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database; then k=2 is initialized; and the sequence bitmap and position bitmap of all k-patterns are generated based on the sequence bitmap and position bitmap of all high-weight frequent (k-1)-patterns; a high-weight frequent k-pattern is obtained based on the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database; finally, it is determined whether k is equal to a preset pattern threshold. If so, the process ends; if not, k is increased by 1, and the process returns to execute based on all high-weight frequent (k-1)-patterns. The steps of generating sequence bitmaps and position bitmaps of all k-patterns by re-frequent (k-1)-pattern sequence bitmaps and position bitmaps, the present invention fully considers the weight differences between different sequences, and can more accurately reflect the relative importance between them. At the same time, the present invention adopts innovative binary sequence bitmaps and position bitmaps to represent the positions where sequence data and patterns appear. This compact data structure not only significantly reduces storage overhead, but also makes it possible to achieve fast pattern matching through bit operations. Through the present invention, we can effectively mine sequence patterns that appear frequently and have high weights. These high-quality patterns will provide more reliable and valuable decision-making basis for various practical applications. It solves the problem that the existing sequence pattern mining methods mainly focus on the frequency of patterns and cannot fully reflect the true importance of patterns. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 A flowchart of a sequential pattern mining method according to embodiment 1 of the present invention;
[0059] Figure 2 is an overall flow chart of the BIMAP algorithm of an embodiment of the present invention;
[0060] Figure 3 A schematic diagram of the search space of the BIMAP algorithm according to an embodiment of the present invention;
[0061] Figure 4 A schematic diagram of the structure of a sequential pattern mining device according to embodiment 2 of the present invention;
[0062] Figure 5 This is a structural schematic diagram of a sequence pattern mining device according to Example 3 of the present invention. DETAILED DESCRIPTION
[0063] In order to enable those skilled in the art to better understand the technical solution of the present invention, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0064] It can be understood that, in the absence of conflict, the various embodiments of the present invention and the various features in the embodiments can be combined with each other.
[0065] It can be understood that, for the convenience of description, the drawings of the present invention only show the parts related to the present invention, while the parts irrelevant to the present invention are not shown in the drawings.
[0066] It can be understood that each unit and module involved in the embodiments of the present invention may correspond to only one physical structure, or may be composed of multiple physical structures, or multiple units and modules may be integrated into one physical structure.
[0067] It can be understood that the terms "first", "second", etc. in the embodiments of the present invention are used to distinguish different objects, or to distinguish different processing of the same object, rather than to describe a specific order of objects.
[0068] It can be understood that, without conflict, the functions and steps marked in the flowcharts and block diagrams of the present invention may occur in an order different from that marked in the drawings.
[0069] It is understood that the flowcharts and block diagrams of the present invention illustrate the possible architectures, functions, and operations of the systems, devices, equipment, and methods according to the various embodiments of the present invention. Each box in the flowchart or block diagram may represent a unit, module, program segment, or code, which contains executable instructions for implementing the specified functions. Moreover, each box or combination of boxes in the block diagram and flowchart may be implemented by a hardware-based system that implements the specified functions, or may be implemented by a combination of hardware and computer instructions.
[0070] It can be understood that the units and modules involved in the embodiments of the present invention can be implemented by software or hardware. For example, the units and modules can be located in a processor.
[0071] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, some technical terms involved in the embodiments of the present invention are briefly explained below.
[0072] Embodiment 1:
[0073] This embodiment provides a sequential pattern mining method, such as Figure 1 As shown, the method includes:
[0074] S1, calculate the sequence bitmap and position bitmap of each 1-pattern binary based on the sequence database.
[0075] In this embodiment, a 1-pattern refers to a sequence pattern with a length of 1. For example, in the sequence database D shown in Table 1, the 1-pattern includes {a}, {b}, {c}, {d}, and {e}.
[0076] Table 1: Sequence database D
[0077]
[0078]
[0079] In this embodiment, the sequence bitmap indicates the specific position of each element in the pattern in the sequence containing the pattern, and the position bitmap indicates the specific position of each item in the pattern in the sequence containing the pattern. For example, the 1-pattern {a} exists in the sequences S1, S3, and S5, but does not exist in the sequences S2 and S5, so the sequence bitmap of {a} is
[10110] ; since item a is the first in the sequences S1, S3, and S5, the position bitmap of {a} is [10000, 0, 10000, 10000, 0].
[0080] It should be noted that the method of using binary bitmap to store sequence information and position information has high computational efficiency, thereby improving the overall efficiency of the algorithm. In addition, the method of storing pattern information can also use list storage or tree storage structure, which can also store pattern information, but their efficiency varies.
[0081] S2, obtaining a high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database.
[0082] In this embodiment, taking the user's purchase sequence as an example, not all sequences have the same importance (members of different consumption levels). By introducing weights, the relative importance of different objects in the real world can be more accurately reflected, so that patterns in those important sequences are given priority in the mining process. For example, in Table 1, the weight of sequence S1 is 3, and the weight of sequence S2 is 5.
[0083] Optionally, the step of calculating the high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database specifically includes:
[0084] Calculate the support of each 1-pattern according to the number of values 1 stored in the sequence bitmap of each 1-pattern;
[0085] For each sequence whose value is 1 in the sequence bitmap of each 1-pattern, the weights corresponding to the corresponding sequences are accumulated and divided by the total weight of the sequence database to obtain the weighted support of each 1-pattern;
[0086] Calculating a comprehensive evaluation index according to the support and weighted support of each of the 1-patterns;
[0087] The 1-pattern whose support is greater than or equal to a preset minimum support threshold, whose weighted support is greater than or equal to a preset minimum weight support threshold, and whose comprehensive evaluation index is greater than or equal to a preset minimum comprehensive score threshold is determined as a high-weight frequent 1-pattern.
[0088] In this embodiment, the support of each 1-pattern is the number of values 1 stored in the sequence bitmap divided by the total number of sequences in the sequence database D. For example, according to Table 1, the support of the 1-pattern {a} is sup({a})=3 / 5=0.6.
[0089] In this embodiment, the weighted support of each of the 1-patterns is the sum of the weights of each sequence with a value of 1 divided by the total weight of the sequence database. For example, according to Table 1, the weighted support of the 1-pattern {a} is weiSup({a}) = (3+1+2) / (3+5+1+2+3) = 0.43.
[0090] In this embodiment, for each of the 1-patterns, the product of the predefined parameter α and the support of the 1-pattern can be calculated first, and then the product of 1-α and the weighted support of the 1-pattern can be calculated, and then the sum of the two products can be calculated to obtain the comprehensive evaluation index of the 1-pattern. For example, taking α=0.5 as an example, according to Table 1, the comprehensive evaluation index of the 1-pattern {a} Score({a})=0.5*0.6+0.5*0.43=0.515 is obtained.
[0091] In this embodiment, the minimum support threshold minSup=0.5, the minimum weight support threshold minWeiSup=0.4, and the minimum comprehensive score threshold minScore=0.5 are set, and {a} is a high-weight frequent 1-pattern.
[0092] S3, initialize k=2;
[0093] S4, generating sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns.
[0094] In this embodiment, the (K-1)-pattern refers to a sequence pattern of length K-1, and the sequence bitmaps and position bitmaps of all k-patterns can be obtained from the sequence bitmap and position bitmap of the (k-1)-pattern. The sequence bitmap and position bitmap of the k-pattern are generated only when the (k-1)-pattern is a high-weight frequent pattern.
[0095] Optionally, generating the sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns specifically includes:
[0096] Perform bitwise AND operation on the sequence bitmaps of any two high-weight frequent (k-1)-patterns among all high-weight frequent (k-1)-patterns to obtain the sequence bitmaps of all k-patterns;
[0097] For each sequence whose value is 1 in the sequence bitmap of each of the k-patterns, obtain the position bitmaps of the sequences of two high-weight frequent (k-1)-patterns constituting the k-pattern, perform a bitwise OR operation on the two position bitmaps, and for each sequence whose value is 0 in the sequence bitmap of each of the k-patterns, set the corresponding position bitmap to 0, thereby obtaining the position bitmaps of all k-patterns.
[0098] In this embodiment, taking the 2-mode {a, b} as an example, the sequence bitmap
[10110] of {a} and the sequence bitmap
[11111] of {b} are ANDed, that is, 10110AND 11111=10110, and the sequence bitmap of the 2-mode {a, b} is obtained as
[10110] . The position bitmap of each sequence with a value of 1 is bitwise ORed, and the other positions are 0, and the calculation is as follows:
[0099] Sequence S1:1000OR 0100=11000
[0100] Sequence S2:0
[0101] Sequence S3: 10000 OR 01000 = 11000
[0102] Sequence S4: 10000 OR 010000 = 11000
[0103] Sequence S5:0
[0104] That is, the position bitmap of the 2-mode {a,b} is [11000,0,11000,11000,0].
[0105] S5, obtaining a high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database.
[0106] Optionally, obtaining a high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database specifically includes:
[0107] Calculate the support of each k-pattern according to the number of values 1 stored in the sequence bitmap of each k-pattern;
[0108] For each sequence whose value is 1 in the sequence bitmap of each k-pattern, the weights corresponding to the corresponding sequences are accumulated and divided by the total weight of the sequence database to obtain the weighted support of each k-pattern;
[0109] Calculating a comprehensive evaluation index according to the support and weighted support of each of the k-patterns;
[0110] The k-pattern whose support is greater than or equal to a preset minimum support threshold, whose weighted support is greater than or equal to a preset minimum weight support threshold, and whose comprehensive evaluation index is greater than or equal to a preset minimum comprehensive score threshold is determined as a high-weight frequent k-pattern.
[0111] In this embodiment, the support of each k-pattern is the number of values 1 stored in the sequence bitmap divided by the total number of sequences in the sequence database D. For example, according to Table 1, the support of the 2-pattern {a, b} = 3 / 5 = 0.6.
[0112] In this embodiment, the weighted support of each k-mode is the cumulative sum of the weights of each sequence with a value of 1 divided by the total weight of the sequence database. For example, according to Table 1, the weighted support of the 2-mode {a, b} is weiSup({a, b})=3+1+2 / 14=0.43.
[0113] Optionally, the comprehensive evaluation index is calculated according to the following formula:
[0114] score(k)=α*sup(k)+(1-α)*weiSup(k)
[0115] Where score(k) is the comprehensive evaluation index of the k-mode, α is a predefined parameter used to adjust the relative importance of support and weighted support, α∈[0,1], sup(k) is the support of the k-mode, and weiSup(k) is the weighted support of the k-mode.
[0116] In this embodiment, taking α=0.5 as an example, the comprehensive evaluation index of the 2-mode {a,b} Score({a,b})=α*sup({a,b})+(1-α)weiSup({a,b})=0.6*0.5+0.5*0.43=0.515.
[0117] S6, determining whether k is equal to a preset mode threshold, if so, ending the process, if not, increasing k by 1 and returning to step S4;
[0118] In this embodiment, the mode threshold can be set according to actual conditions, and the mode threshold is less than or equal to the total number of all items in the database. For example, there are 5 different items in the sequence database D in Table 1, namely a, b, c, d, and e, and the mode threshold is less than or equal to 5.
[0119] Optionally, the method further comprises:
[0120] Create a corresponding frequent item object according to each high-weight frequent 1-pattern and add it to the pre-established high-weight frequent pattern set;
[0121] Creating a corresponding frequent item object according to each high-weight frequent k-pattern, and adding it to the high-weight frequent pattern set;
[0122] Each frequent item object includes a pattern, support corresponding to the pattern, weighted support, comprehensive evaluation index, sequence bitmap and position bitmap.
[0123] In this embodiment, the support, weighted support, comprehensive evaluation index, sequence bitmap and position bitmap of each pattern can be easily viewed through the high-weight frequent pattern set, and it is also convenient to generate and explore all possible k-item combinations based on the (k-1)-pattern using a breadth-first search method.
[0124] Optionally, after obtaining the high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database, the method further comprises:
[0125] For the high-weight frequent k-pattern, using the weighted support in the high-weight frequent pattern set, obtain the confidence of multiple sub-patterns from X to Y;
[0126] Constructing a weighted confidence matrix of the high-weight frequent k-pattern according to the confidences of the multiple sub-patterns from X to Y;
[0127] Strong association rules are identified based on the weight confidence matrix.
[0128] It should be noted that in addition to the weight, the confidence of a pattern is also a key indicator for evaluating its importance. Confidence reflects the strength of association between elements within the pattern. Patterns with high confidence often have stronger predictive ability and practical value, but existing algorithms have not fully considered the confidence factor.
[0129] Specifically, the confidence is calculated according to the following formula:
[0130] conf(X→Y)=weiSup(X∪Y) / weiSup(X)
[0131] Where conf(X→Y) represents the confidence from subpattern X to Y, weiSup(X∪Y) represents the weighted support of the union of subpatterns X and Y, weiSup(X) represents the weighted support of subpattern X, X and Y are non-empty subsequences of the high-weight frequent k-pattern, and
[0132] Among them, if conf(X→Y) is not less than the preset minimum confidence threshold, it means that X and Y are strongly associated.
[0133] In this embodiment, taking a high-weight frequent 2-pattern as an example, for the high-weight frequent 2-pattern, the confidence of sub-patterns a→b, b→a, a→c, c→d, etc. can be calculated, and then a weight confidence matrix can be constructed. For example, according to Table 1, Conf(a→b)=weiSup(a,b) / weiSup(a)=0.43 / 0.43=1; Conf(b→a)=weiSup(a,b) / weiSup(b)=0.43 / 1.0=0.43, etc., and the final weight confidence matrix can be shown in Table 2:
[0134] Table 2: Weighted confidence matrix
[0135]
[0136]
[0137] Assuming the minimum confidence minConf=0.7, according to the above weight confidence matrix, when product a appears, product b must appear, indicating that a and b have a strong correlation. Similarly, when product a appears, item c must also appear, and when item a appears, item d has a high probability of appearing, indicating that there is a strong correlation between a and d. Therefore, a sales strategy that binds a and b and / or a and c can be formulated.
[0138] It should be noted that the sequential pattern mining method provided by the present invention has the following characteristics:
[0139] a) Introducing sequence weights: The present invention takes into account the weight differences of different sequences. By assigning different weights to each sequence, the relative importance of different sequences can be more accurately reflected, thereby giving priority to patterns in important sequences during the mining process.
[0140] b) Organic combination of weight and support: The algorithm introduces the concept of weighted support (weiSup), which combines the importance weight of an item or sequence with its frequency of occurrence. This enables the algorithm to more accurately assess the actual value of a pattern and avoids the bias of relying solely on frequency.
[0141] e) Efficient binary representation: Binary sequence bitmap and position bitmap are used to represent sequence data and pattern occurrence positions. This compact data structure not only greatly reduces storage overhead, but also enables fast pattern matching and support calculation through bit operations.
[0142] d) A comprehensive evaluation function is introduced to make the algorithm more applicable by adjusting parameters, so that it can cope with different types of data sets and application scenarios, and the robustness of the algorithm is enhanced, reducing excessive reliance on a single indicator.
[0143] e) Multi-dimensional confidence evaluation: The algorithm introduces a confidence matrix to comprehensively evaluate the bidirectional correlation strength between elements in the sequence pattern, providing a new perspective for in-depth understanding of complex patterns.
[0144] f) Customizable mining strategies: The algorithm supports users to adjust parameters such as minimum support and minimum confidence according to specific needs to achieve flexible pattern mining.
[0145] In a specific embodiment, the sequential pattern mining method is based on a bitmap-accelerated weighted association sequential pattern mining algorithm BIMAP. The overall flow chart of the BIMAP algorithm can be shown as follows: Figure 2 As shown in the figure, after data preprocessing, the 1-mode is first initialized, the sequence bitmap and position bitmap of the 1-mode are calculated, and the bitmap is used to represent efficient storage information. Then, the support, weighted support, and comprehensive evaluation index of the 1-mode are calculated, and it is determined whether these parameters meet the defined threshold. If not, pruning is performed. If so, a candidate K-mode is generated, the sequence bitmap and position bitmap of the K-mode are calculated, and the parameter values are quickly calculated using two (k-1)-mode bitmaps. The parameter values and indicators of the K-mode are calculated, the confidence is calculated using the weighted support, a weighted confidence matrix is constructed, strong association rules are identified, and finally a high-weight association mode is output.
[0146] In order to better describe the algorithm of the present invention, combined with the process Figure 1 The present invention introduces a weighted association sequence pattern mining method based on bitmap acceleration under transaction purchase, which includes the following three important steps:
[0147] Step 1: Concept Definition
[0148] In order to better describe the algorithm, the concepts involved in the algorithm are defined:
[0149] Definition 1: Weight refers to a non-negative real value assigned to each sequence in the sequence database, indicating the importance or influence of the sequence. For the sequence database D = {S1: w1, S2: w2, S3: w3, ..., Sn: wn}, the weight w: D → R+, where R+ represents a set of non-negative real numbers and wn represents the weight of the sequence Si.
[0150] Definition 2: The weighted support weiSup of item P is the ratio of the sum of the weights of all sequences containing the pattern to the total weight of the database, which is expressed as in
[0151] Definition 3: For pattern P =<a1,a2,a3,...ak> , the confidence of the subpattern X to Y represents the probability that a sequence containing X also contains Y, which is expressed as conf(X→Y)=weiSup(X∪Y) / weiSup(X), where X and Y are non-empty subsequences of P, and
[0152] Definition 4: The confidence matrix is a k*k matrix (k is the length of pattern P), where each element CM[i][j] represents the confidence from the i-th element to the j-th element. For pattern P =<a1,a2,a3,...ak> , CM[i][j]=conf(ai→aj)=weiSup(ai→aj) / weiSup(ai).
[0153] Definition 5: A sequence bitmap is a set of binary vectors that represent the specific position of each element in a pattern in the sequence containing the pattern. For a pattern P and a database D = {S1: w1, S2: w2, S3: w3, ..., Sn: wn}, the sequence bitmap of pattern P is SeBina(P) = [b1, b2, ..., bn], where bi = 1 if Otherwise bi=0.
[0154] For example: Suppose there is a sequence database
[0155] D = {S1:w1, S2:w2, S3:w3, S4:w4, S5:w5} and a pattern P =<a,b> , if P appears in S1, S3 and S4, then SB(P) = [1,0,1,1,0].
[0156] Definition 6: The position bitmap is a set of binary vectors that represent the specific position of each item in the pattern in the sequence containing the pattern. Given a pattern P =<a1,a2,a3,...ak> And the sequence database D = {S1, S2, ..., Sn}, the sequence bitmap SB (P, S) = [b1, b2, ... bk], where pbi = [p1, p2, ... pm], if ej = ai, Pj = 1, otherwise pj = 0.
[0157] For example: Suppose there is a sequence S=<a,c,b,a,c,b> And pattern P=(a,b), then the position bitmap PB(P,S): PB1 (corresponding to a): [1,0,0,1,0,0], PB2 (corresponding to b): [0,0,1,0,0,1].
[0158] Definition 7: Given a parameter α∈[0,1], the comprehensive score of pattern P is defined as: score(p)=α*sup(p)+(1-α)*weiSup(p), where α is a user-defined parameter used to adjust the relative importance of support and weighted support. When α=1, score(p) degenerates to traditional support, when α=0, score(p) degenerates to weighted support, and when 0<α<1, score(p) comprehensively considers the importance of the frequency and weight of the pattern.
[0159] Step 2: Algorithm flow
[0160] (1) The detailed steps of the algorithm are as follows:
[0161] Algorithm input: pre-processed sequence transaction database D, minimum weight support minWeiSup, minimum confidence minConf;
[0162] Output: All high-weight associated frequent patterns.
[0163] The algorithm first creates an empty set I, traverses each sequence S in the database D, and adds each 1-pattern that appears in the database D to the set I.
[0164] Create a nested dictionary set seqbitMap to store each item and the sequence bitmap where each item is located, that is, the sequence position.
[0165] Create a pattern position bitmap posBitMaps to store the specific position of each item in a sequence.
[0166] Create a dictionary set Support of pattern support to store the support support of each pattern, and use the sequence bitmap of the pattern to calculate the support Sup(i) of the pattern.
[0167] Create a weightSupport dictionary set to store the weighted support weight of each pattern.
[0168] Create a rulesMap dictionary collection to store the associated rules for each pattern.
[0169] Create a scoreMap dictionary collection to store the comprehensive evaluation value of each mode.
[0170] While traversing each row of database D, the total weight of D |weight(D)| is saved and accumulated.
[0171] The algorithm traverses each row of the database and first constructs the sequence bitmap of the 1-pattern {i}: initialize the nested dictionary set seqBitMaps, and initialize the 1-pattern position bitmap posBitMaps. If the pattern {i} appears in Si, then add the 1-pattern to seqBitMaps and record that the i-th sequence position is set to 1, and the remaining positions are set to 0. If the pattern {i} appears at the j-th position in a sequence, then the j-th position in posBitMaps is set to 1, and the rest are 0. Because seqBitMaps and posBitMaps are nested, the specific position of a pattern can be quickly located through seqBitMaps and posBitMaps. When a new pattern is traversed, the support Sup(i) of the pattern is calculated using the number of 1s stored in the sequence bitmap of the pattern.
[0172] Each time a row of sequence is traversed, the sequence weight weight corresponding to the sequence in seqBitMaps(i) is recorded, the sequence Si corresponding to the 1-pattern {i} is calculated, the sum of the weighted support ∑weiSup(i) is calculated, and its value is used to calculate the final weighted support: weiSup(i) = ∑weiSup(i) / |weiSup(D)|, and the comprehensive score of the pattern score(i) = α*sup({a})+(1-α)*weiSup({a}) is further calculated.
[0173] If the parameter thresholds of the 1-pattern satisfy sup(i)≥minSup, weiSup(i)≥minWeiSup and score(i)≥minscore(i), the pattern is defined as a high-weight frequent pattern, and an object set named FreItemset is created. Each object fi contains: pattern {i}, support sup(i), weighted support weiSup(i), comprehensive score score(i), sequence bitmap seqBitMap(i) and position bitmap posBitMaps[i]. The object fi is added to the high-weight frequent pattern set FreItemset as a candidate set for iteration.
[0174] The algorithm uses the high-weight 1-patterns in the set FreItemset to generate and explore all possible 2-item combinations in a breadth-first search manner. First, obtain the sequence bitmaps of the two 1-patterns, perform a bitwise AND operation on the two sequence bitmaps, and obtain the sequence bitmap of the 2-pattern. Secondly, for each sequence with a value of 1 in the sequence bitmap, obtain the position bitmap of the two 1-patterns that constitute the 2-pattern in the sequence, and perform a bitwise OR operation on the two position bitmaps. For sequences with a value of 0 in the sequence bitmap, the position bitmaps are all set to 0.
[0175] Then the algorithm calculates the support, weighted support, and comprehensive score of the 2-pattern. Traverse the sequence bitmap, accumulate the corresponding weights for the sequence positions with a value of 1, and then divide the accumulated weights by the total weight of the database D to obtain the weighted support. If the support sup of the 2-pattern is not less than minSup, the weighted support weiSup is not less than minWeiSup, and the comprehensive score score is not less than minScore, then the 2-pattern is a high-weight frequent pattern and continues to be stored in the object fi as a candidate pattern. Calculate all high-weight support 2-patterns, and further calculate their weighted confidence: Conf(x→y)=weiSup(x,y) / weiSup(y). If Conf(x→y) is not less than minConf, it means that patterns x and y have a strong correlation, which means that as long as x appears, y is likely to appear. List the confidence matrix based on the weighted confidence of the 1-pattern and 2-pattern. According to the confidence matrix, the degree of correlation between any two items can be clearly observed.
[0176] Similarly, find high-weight associated 3-patterns based on all high-weight frequent 2-patterns and expand to n-patterns.
[0177] A high-association frequent pattern that meets the pattern support is searched in breadth-first order. The search space is as follows:
[0178] (2) The detailed process of the algorithm is described as follows:
[0179] Input: sequence transaction database D, minimum weight support minWeiSup, minimum confidence minConf;
[0180] Output: All high-weight associated frequent patterns.
[0181] In order to introduce this algorithm in detail and clearly, it is introduced step by step:
[0182] Create an empty set I, traverse each sequence S in database D, and add each 1-pattern that appears in database D to set I.
[0183] While traversing each row of database D, save and calculate the total weight of D |weight(D)|.
[0184] Create a nested dictionary set seqbitMap to store the sequence bitmap of each item. The bitmap dictionary stores the sequence position of item {i}. Create another dictionary set Support to store the support support of each pattern, and use the sequence bitmap of the pattern to calculate the support Sup(i) of the pattern.
[0185] First, construct the sequence bitmap of 1-pattern {i}: initialize seqBitMaps to an all-0 bitmap, and initialize 1-pattern position bitmap posBitMaps. If pattern {i} appears in Si, the i-th position in seqBitMaps is set to 1, and the rest are set to 0. If pattern {i} appears at the j-th position in a sequence, the j-th position in posBitMaps is set to 1, and the rest are set to 0.
[0186] Create a weightSupport dictionary set to store the weighted support weight of each pattern.
[0187] Create a rulesMap dictionary collection to store the associated rules for each pattern.
[0188] Create a scoreMap dictionary collection to store the comprehensive evaluation value of each mode.
[0189] Traverse seqBitMaps(i) to obtain the weight wi of the sequence Si corresponding to pattern {i}, calculate the support sup({a}) of {i} and the sum of weighted support ∑weiSup(i), and use their values to calculate the final weighted support: weiSup(i) = weiSup(i) / |weiSup(D)|, and further calculate the comprehensive score score(i) = α*sup({a})+(1-α)*weiSup({a}).
[0190] If sup(i)≥minSup, weiSup(i)≥minWeiSup and score(i)≥minscore(i), create a new FreItemset object fi containing: pattern {i}, support sup(i), weighted support weiSup(i), comprehensive score score(i), sequence bitmap seqBitMap(i) and position bitmap posBitMaps[i], and add object fi to high-weight frequent patterns. Finally, calculate the confidence of {i}. If conf(i)≥minConf, pattern {i} is regarded as a high-weight associated frequent pattern. Finally, use the 1-pattern candidate set to calculate the confidence. If conf(i→j)≥minConf, it means that if the user buys item i again, there is a high probability that he will also buy item j.
[0191] Using the 1-patterns in the object fi in the candidate set, a breadth-first search method is used to generate and explore all possible 2-item combinations. First, the sequence bitmaps seqBitMaps of the two 1-pattern objects in fi are obtained, and the two sequence bitmaps are bitwise ANDed to obtain the sequence bitmaps of the 2-patterns. Secondly, for each sequence with a value of 1 in the sequence bitmap of the generated 2-item, the corresponding position bitmaps posBitMaps of the two 1-patterns in the sequence are obtained, and the position bitmaps of the two 1-patterns are bitwise ORed to form the position bitmaps of the 2-patterns. For sequences with a value of 0 in the sequence bitmap, the position bitmaps are all set to 0.
[0192] Similarly, the algorithm calculates the support Sup(i), weighted support weiSup(i), and comprehensive score score(i) of the 2-pattern. Traverse the sequence bitmap, calculate the sequence position with a value of 1 in the 2-pattern set seqBitMap(i), and add the number of sequences to obtain the sequence support number sup(i) and the corresponding weight of the pattern, and then divide the accumulated weight by the total weight of the database D to obtain the weighted support weiSup(i) of the 2-pattern. If the support sup(i) of the 2-pattern is not less than minSup(i), the weighted support weiSup(i) is not less than minWeiSup(i), and the comprehensive score score(i) is not less than minScore(i), then the 2-pattern is a high-weight frequent pattern and continues to be stored in the object fi as a candidate pattern. Calculate all high-weight support 2-modes, and further calculate their weighted confidence: Conf(x→y)=weiSup(x,y) / weiSup(y). If Conf(x→y) is not less than minConf, it means that mode x and y have a strong correlation, which means that as long as x appears, y is likely to appear. List the confidence matrix based on the weighted confidence of 1-mode and 2-mode. According to the confidence matrix, the correlation degree of any two items can be clearly observed.
[0193] Similarly, find high-weight associated 3-patterns based on all high-weight frequent 2-patterns and expand to n-patterns.
[0194] The high-association frequent pattern that meets the pattern support is traversed by breadth-first search, and its search space is as follows: Figure 3 shown.
[0195] The algorithm merges high-weight associated frequent 1-patterns according to breadth-first traversal to generate a pattern with an item length of 2. The 2-pattern requires bitwise operation of the sequence bitmaps of two highly associated frequent 1-patterns to generate a new 2-pattern sequence bitmap, and then calculates the position bitmap based on the sequence bitmap.
[0196] Finally, the algorithm calculates the confidence of the high-correlation frequent 1-pattern and establishes a confidence expansion matrix based on the confidence of the high-correlation frequent 1-pattern (the vertical axis represents the preceding pattern and the horizontal axis represents the succeeding pattern), as shown in Table 2.
[0197] According to the confidence in Table 2, when a certain pattern appears, the other pattern will definitely appear (conf=1), indicating that the two patterns are strongly associated (conf≥minConf). If conf≥minConf, it means that when a certain pattern appears, the other pattern is likely to appear. If conf<minConf, it means that the two patterns are less associated or not associated.
[0198] Similarly, we perform bitmap operations based on two high-weight frequent patterns of length n-1 to obtain n-patterns, and then calculate the parameters of n-patterns to see if they meet the high-weight patterns. When any two high-weight n-1 patterns are combined into a new pattern, the n-patterns that meet the parameter threshold will be retained, otherwise they will be pruned. This method greatly reduces the amount of calculations and improves the efficiency of the algorithm.
[0199] Step 3: Algorithm Example
[0200] In order to better describe the algorithm of the present invention, a detailed example is given below:
[0201] The following describes the algorithm using a detailed example in conjunction with the sequence database D in Table 1:
[0202] First, customize the algorithm parameters: minimum support threshold minSup = 0.5, minimum weight support threshold minWeiSup = 0.4, minimum confidence threshold minConf = 0.7, minimum comprehensive score threshold minScore = 0.5. The algorithm starts to scan the database D once, calculates the sequence bitmap and position bitmap of each pattern while scanning, and constructs the sequence bitmap of pattern {a}:
[0203] Sequence S1:1 (present)
[0204] Sequence S2:0 (does not exist)
[0205] Sequence S3:1 (present)
[0206] Sequence S4:1 (present)
[0207] Sequence S5:0 (does not exist)
[0208] Therefore, the sequence bitmap of {a} is:
[10110] , and then the position bitmap of pattern {a} is constructed:
[0209] Sequence S1:10000
[0210] Sequence S2:0
[0211] Sequence S3:10000
[0212] Sequence S4:10000
[0213] Sequence S5:0
[0214] {a} position bitmap: [10000,0,10000,10000,0]
[0215] According to the bitmap of {a}, we calculate the support sup({a})=|{S1,S3,S4}| / |D|=3 / 5=0.6 and the weighted support: weiSup({a})=weight({a}) / |weight(D)|=(3+1+2) / (14)=0.43>minWeiSup, and further use the comprehensive scoring function to combine the support and weighted support Score(a)=α*sup({a})+(1-α)*weiSup({a})=0.6*0.5+0.5*0.43=0.515>minScore. Therefore, {a} is a high-weight frequent pattern.
[0216] Construct a sequence bitmap of mode {b}:
[0217] Sequence S1:1 (present)
[0218] Sequence S2:1 (present)
[0219] Sequence S3:1 (present)
[0220] Sequence S4:1 (present)
[0221] Sequence S5:1 (present)
[0222] Therefore, the sequence bitmap of {b} is:
[11111] , and then the position bitmap of pattern {b} is constructed:
[0223] Sequence S1:01000
[0224] Sequence S2:10000
[0225] Sequence S3:01000
[0226] Sequence S4:01000
[0227] Sequence S5:10000
[0228] {b} position bitmap: [01000,10000,01000,01000,10000]
[0229] Calculate support based on the bitmap of {b}
[0230] sup({b})=|{S1,S3,S4}| / |D|=5 / 5=1, weighted support: weiSup({b})=
[0231] weiSup({b}) / |weight(D)|=3+5+1+2+3 / 14=1>minWeiSup, further using the comprehensive scoring function to combine support and weighted support
[0232] Score(b)=α*sup({b})+(1-α)
[0233] *weiSup({b})=1*0.5+0.5*1=1>minScore. Therefore {b} is a high-weight frequent pattern
[0234] Construct a sequence bitmap of pattern {c}:
[0235] Sequence S1:1 (present)
[0236] Sequence S2:1 (present)
[0237] Sequence S3:1 (present)
[0238] Sequence S4:1 (present)
[0239] Sequence S5:0 (exists)
[0240] Therefore, the sequence bitmap of {c} is:
[11110] , and then the position bitmap of pattern {c} is constructed:
[0241] Sequence S1:00100
[0242] Sequence S2:01000
[0243] Sequence S3:00100
[0244] Sequence S4:00100
[0245] Sequence S5:0
[0246] {c} position bitmap: [00100,01000,00100,00100,00000]
[0247] According to the bitmap of {c}, the support is calculated as: sup({c}) = sup({c}) / |sup(D)| = 4 / 5 = 0.8> minSup, and the weighted support is: weiSup({c}) = weiSup({c}) / |weight(D)| = 3+5+1+2 / 14 = 0.78> minWeiSup. The comprehensive scoring function is further used to combine the support and weighted support Score(c) = α*sup({c})+(1-α)*weiSup({c}) = 0.8*0.5+0.5*0.78 = 0.79> minScore. Therefore, {c} is a high-weight frequent pattern.
[0248] Construct a sequence bitmap of mode {d}:
[0249] Sequence S1:1 (present)
[0250] Sequence S2:0 (does not exist)
[0251] Sequence S3:0 (does not exist)
[0252] Sequence S4:1 (present)
[0253] Sequence S5:1 (present)
[0254] Therefore, the sequence bitmap of {d}:
[10011] , then construct the position bitmap of pattern {d}:
[0255] Sequence S1:00010 (4th position)
[0256] Sequence S2:0 (position 0)
[0257] Sequence S3:0 (position 0)
[0258] Sequence S4:00010 (position 4)
[0259] Sequence S5:01000 (2nd position)
[0260] {d} position bitmap: [00010,0,0,00010,01000]
[0261] Based on the bitmap of {d}, support is calculated: sup({d})=sup({d}) / |sup(D)|=3 / 5=0.6>minSup weighted support: weiSup({d})=weiSup({d}) / |weight(D)|=3+2+3 / 14=0.57>minWeiSup, and the comprehensive scoring function is further used to combine support and weighted support Score(d)=α*sup({d})+(1-α)*weiSup({d})=0.6*0.5+0.5*0.57=0.585>minScore. Therefore, {d} is a high-weight frequent pattern
[0262] Construct a sequence bitmap of mode {e}:
[0263] Sequence S1:0 (does not exist)
[0264] Sequence S2:1 (present)
[0265] Sequence S3:1 (present)
[0266] Sequence S4:0 (does not exist)
[0267] Sequence S5:1 (present)
[0268] Therefore, the sequence bitmap of {e} is:
[01101] , and then the position bitmap of pattern {a} is constructed:
[0269] Sequence S1:0
[0270] Sequence S2:00100 (position 3)
[0271] Sequence S3:00010 (position 4)
[0272] Sequence S4:0
[0273] Sequence S5:00100 (position 3)
[0274] {e} position bitmap: [0,00100,00010,0,00100]
[0275] According to the bitmap of {e}, support is calculated as: sup({e}) = sup({e}) / |sup(D)| = 3 / 5 = 0.6>minSup weighted support: weiSup({e}) = weiSup({e}) / |weight(D)| = 5+1+3 / 14 = 0.64>minWeiSup, and the comprehensive scoring function is further used to combine support and weighted support Score(e) = α*sup({e})+(1-α)*weiSup({e}) = 0.6*0.5+0.5*0.64 = 0.62>minScore. Therefore, {e} is a high-weight frequent pattern.
[0276] According to the above calculation, we can know that the patterns {a}, {b}, {c}, {d}, {e} are high-weight frequent patterns, and then the high-weight frequent 2-pattern is calculated based on the high-weight frequent 1-pattern.
[0277] According to the sequence bitmap and position bitmap of the frequent pattern one, the sequence bitmap and position bitmap of the frequent pattern two are obtained:
[0278] {a,b} constructs a sequence bitmap of pattern {a,b}:
[0279] 10110AND 11111=10110
[0280] Therefore, the sequence bitmap of {a,b} is:
[10110] , and then the position bitmap of the pattern {a,b} is constructed:
[0281] Sequence S1:1000OR 0100=11000
[0282] Sequence S2: 0OR 10000 (if one side is all 0, it will not be counted)
[0283] Sequence S3: 10000 OR 01000 = 11000
[0284] Sequence S4: 10000 OR 010000 = 11000
[0285] Sequence S5: 00000 (same as above)
[0286] Position bitmap of {a,b}:[11000,0,11000,11000,0]
[0287] According to the sequence bitmap of {a,b}, the support is calculated as: sup({a,b})=sup({a,b}) / |sup(D)|=3 / 5=0.6>minSup weighted support: weiSup({a,b})=weight({a,b}) / |weight(D)|=3+1+2 / 14=0.43>minSupWei, and the comprehensive scoring function is further used to combine the support and weighted support Score(a,b)=α*sup({a,b})+(1-α)*weiSup({a,b})=0.6*0.5+0.5*0.43=0.515>minScore. Therefore, {a,b} is a high-weight frequent pattern.
[0288] {a,c} builds the sequence bitmap of pattern {a,c}:
[0289] 10110AND 11110=10110
[0290] Therefore, the sequence bitmap of {a,c} is:
[10110] , and then the position bitmap of the pattern {a,b} is constructed:
[0291] Sequence S1: 1000 OR 00100 = 10100
[0292] Sequence S2:0
[0293] Sequence S3: 10000 OR 00100 = 10100
[0294] Sequence S4: 10000 OR 01000 = 10100
[0295] Sequence S5:0
[0296] Position bitmap of {a,c}: [10100,0,10100,10100,00000]
[0297] Calculate the support according to the sequence bitmap of {a, c}: sup({a, c}) = sup({a, c}) / |sup(D)| = 3 / 5 = 0.6 > minSup, and the weighted support: weiSup({a, c}) = weiSup({a, c}) / |weight(D)| = 6 / 14 = 0.43 > minWeiSup. Further, use the comprehensive scoring function to combine the support and the weighted support Score(a, c) = α * sup({a, c}) + (1 - α) * weiSup({a, c}) = 0.6 * 0.5 + 0.5 * 0.43 = 0.515 > minScore. Therefore, {a, c} is a high-weight frequent pattern.
[0298] Construct the sequence bitmap of the pattern {a, d}:
[0299] 10110 AND 10011 = 10010
[0300] Therefore, the sequence bitmap of {a, d}:
[10010] , and then construct the position bitmap of the pattern {a, d}:
[0301] Sequence S1: 10000 OR 00010 = 10010
[0302] Sequence S2: 0
[0303] Sequence S3: 0
[0304] Sequence S4: 10000 OR 00010 = 10010
[0305] Sequence S5: 0
[0306] The position bitmap of {a, d}: [10010, 0, 0, 10010, 0]
[0307] Calculate the support according to the sequence bitmap of {a, d}: sup({a, d}) = sup({a, d}) / |sup(D)| = 2 / 5 = 0.4 > minSup, and the weighted support: weiSup({a, d}) = weiSup({a, d}) / |weight(D)| = 5 / 14 = 0.36 < minWeiSup. Therefore, there is no need to calculate the comprehensive score of {a, d}, and it is not a high-weight frequent pattern either.
[0308] Construct the sequence bitmap of the pattern {a, e}:
[0309] 10110 AND 01101 = 00100
[0310] Therefore, the sequence bitmap of {a, e}:
[00100] , and then construct the position bitmap of the pattern {a, e}:
[0311] Sequence S1: 0
[0312] Sequence S2: 0
[0313] Sequence S3: 10000 OR 00010 = 10010
[0314] Sequence S4: 0
[0315] Sequence S5: 0
[0316] Position bitmap of {a, e}: [0, 0, 10010, 0, 0]
[0317] Calculate the support degree according to the sequence bitmap of {a, e}: sup({a, e}) = sup({a, e}) / |sup(D)| = 1 / 5 = 0.2 < minSup. Therefore, there is no need to calculate the weighted support degree and comprehensive score of {a, e}. {a, e} is not a high-weight frequent pattern, and there is no need to further calculate its confidence degree.
[0318] After calculating the weighted confidence degrees of all 2-itemsets, further calculate their confidence degrees:
[0319] Conf(a → b) = weiSup(a, b) / weiSup(a) = 0.43 / 0.43 = 1 ≥ minConf
[0320] Conf(b → a) = weiSup(a, b) / weiSup(b) = 0.43 / 1.0 = 0.43 ≤ minConf
[0321] Conf(a → c) = weiSup(a, c) / weiSup(a) = 0.43 / 0.43 = 1 ≥ minConf
[0322] Conf(c → a) = weiSupport(a, c) / weiSup(a) = 0.43 / 0.43 = 1 ≥ minConf
[0323] ……
[0324] Finally, calculate the confidence degrees of the patterns according to all high-weight frequent patterns. Table 2 is an example of a confidence matrix among high-weight frequent 1-patterns: According to the weighted confidence matrix in Table 2, when product a appears, product b will definitely appear, indicating a strong correlation between a and b. Similarly, when product a appears, item c will also definitely appear, and when item a appears, item d has a high probability of appearing, which shows a strong correlation between a and d. Therefore, a sales strategy of bundling a and b and / or a sales strategy of bundling a and c can be formulated.
[0325] It should be noted that the sequential pattern mining method provided by the present invention has the following innovations:
[0326] 1. The algorithm designed by the present invention can identify and prioritize high-weight patterns.
[0327] a) Not all data items or sequences in a user’s purchase sequence have the same importance (members of different consumption levels). By introducing weights, the algorithm can more accurately reflect the relative importance of different objects in the real world.
[0328] b) Not only for the consumption area of the shopping basket, but also for different specific areas and business needs, different data objects are given importance.
[0329] c) The pattern mining results that take weights into consideration are more practical and relevant, and patterns with high weights are more valuable for decision making.
[0330] Implementation:
[0331] Use weighted support (weiSup) instead of traditional support calculation. Consider the weight of the sequence when calculating camera frequency.
[0332] 2. The algorithm designed by the present invention introduces sequence bitmap and position bitmap for the first time, and can quickly generate patterns, position information and parameter calculations using binary bit operations, while providing an efficient expansion structure for generating larger patterns. This storage structure reduces memory usage and scanning times, and greatly improves the calculation speed by using bit operations, which is particularly suitable for processing large-scale, high-dimensional data sets.
[0333] Implementation: Use bit operations to quickly calculate sets containing more items, position information, and parameter values.
[0334] 3. The algorithm designed by the present invention combines the ability to identify frequent patterns while taking weights into consideration.
[0335] a) Frequent patterns reflect common trends and regularities in the data and can help understand the overall structure of the data.
[0336] b) Combining weighted frequent patterns provides a comprehensive evaluation that considers both the importance of the pattern and the frequency of its occurrence in different sequences.
[0337] Implementation method: Use weighted support weiSup to define frequent patterns, while retaining the concept of minimum support, and determine frequent patterns through weighted support.
[0338] 4. The algorithm designed by the present invention has designed a comprehensive scoring mechanism, which not only improves the flexibility and applicability of the algorithm, but also enhances its ability to discover truly valuable patterns. It not only takes into account the frequency factor in traditional data mining, but also incorporates the weight factor that reflects the importance of data. The flexible setting of parameter weights can provide more meaningful screening and identification in various complex data sets and application scenarios.
[0339] Implementation method: According to different types of data sets and application scenarios, different parameter weights are set, and a more practical and comprehensive evaluation result is obtained through the comprehensive evaluation function Score(P)=α*Sup(P)+(1-α)*weiSup(P).
[0340] 5. The algorithm is able to discover strong association rules based on high-weight patterns.
[0341] a) Frequent patterns reflect common trends and regularities in the data and can help understand the overall structure of the data.
[0342] b) Combine the weighted frequent patterns to provide a comprehensive evaluation that takes into account both the importance of the pattern and the frequency of its occurrence.
[0343] Implementation:
[0344] The concept of weighted confidence is introduced, and the confidence is calculated using weighted support.
[0345] A weight confidence matrix was constructed to show the strength of association between patterns.
[0346] 6. The algorithm integrates three dimensions: high weight, frequency, and correlation analysis.
[0347] First, the present invention comprehensively considers multiple dimensions to provide a more comprehensive and in-depth understanding of the data. Second, it can meet multiple analysis goals: important patterns, discover common trends, and reveal strong correlations. Third, it improves the flexibility and applicability of the algorithm and can cope with various data mining tasks by adjusting the threshold.
[0348] The sequential pattern mining method provided by the embodiment of the present invention first calculates the binary sequence bitmap and position bitmap of each 1-pattern based on the sequence database; and obtains the high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database; then initializes k=2; and then generates the sequence bitmap and position bitmap of all k-patterns according to the sequence bitmap and position bitmap of all high-weight frequent (k-1)-patterns; obtains the high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database; finally, determines whether k is equal to the preset pattern threshold, if so, terminates the process, if not, increases k by 1, and returns The step of generating the sequence bitmap and position bitmap of all k-patterns according to the sequence bitmap and position bitmap of all high-weight frequent (k-1)-patterns is performed again. The present invention fully considers the weight differences between different sequences and can more accurately reflect the relative importance between them. At the same time, the present invention adopts innovative binary sequence bitmap and position bitmap to represent the positions where sequence data and patterns appear. This compact data structure not only significantly reduces the storage overhead, but also makes it possible to achieve fast pattern matching through bit operations. Through the present invention, we can effectively mine sequence patterns that appear frequently and have high weights. These high-quality patterns will provide more reliable and valuable decision-making basis for various practical applications. It solves the problem that the existing sequence pattern mining methods mainly focus on the frequency of the pattern and cannot fully reflect the true importance of the pattern.
[0349] Embodiment 2:
[0350] like Figure 4 As shown, this embodiment provides a sequential pattern mining device, which is used to execute the above-mentioned sequential pattern mining method, including:
[0351] A first bitmap calculation module 11, used to calculate a sequence bitmap and a position bitmap of each 1-mode binary based on a sequence database;
[0352] A first frequent pattern acquisition module 12, connected to the first bitmap calculation module 11, is used to calculate a high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database;
[0353] An initialization module 13, connected to the first frequent pattern acquisition module 12, and configured to initialize k=2;
[0354] A second bitmap calculation module 14, connected to the initialization module 13, is used to generate sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns;
[0355] A second frequent pattern acquisition module 15, connected to the second bitmap calculation module 14, is used to calculate and obtain a high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database;
[0356] An iterative judgment module 16, connected to the second frequent pattern acquisition module 15, is used to judge whether k is equal to a preset pattern threshold, if so, the process ends, if not, k is increased by 1, and the process returns to and executes the second bitmap calculation module 14;
[0357] The sequence bitmap indicates the specific position of each element in the pattern in the sequence containing the pattern, and the position bitmap indicates the specific position of each item in the pattern in the sequence containing the pattern.
[0358] Optionally, the first frequent pattern acquisition module 12 specifically includes:
[0359] A first calculation unit, configured to calculate the support degree of each of the 1-patterns according to the number of values 1 stored in the sequence bitmap of each of the 1-patterns;
[0360] A second calculation unit is used for accumulating the weights corresponding to the corresponding sequences for each sequence whose value is 1 in the sequence bitmap of each 1-pattern, and dividing the weights by the total weight of the sequence database to obtain the weighted support of each 1-pattern;
[0361] A third calculation unit, used for calculating a comprehensive evaluation index according to the support and weighted support of each of the 1-modes;
[0362] The first determination unit is used to determine the 1-pattern whose support is greater than or equal to a preset minimum support threshold, weighted support is greater than or equal to a preset minimum weight support threshold, and comprehensive evaluation index is greater than or equal to a preset minimum comprehensive score threshold as a high-weight frequent 1-pattern.
[0363] Optionally, the second bitmap calculation module 14 specifically includes:
[0364] A bitwise AND operation unit, used for performing a bitwise AND operation on the sequence bitmaps of any two high-weight frequent (k-1)-patterns among all high-weight frequent (k-1)-patterns, to obtain the sequence bitmaps of all k-patterns;
[0365] A bitwise OR operation unit is used to obtain, for each sequence whose value is 1 in the sequence bitmap of each k-pattern, the position bitmap of the sequences of two high-weight frequent (k-1)-patterns constituting the k-pattern, perform a bitwise OR operation on the two position bitmaps, and for each sequence whose value is 0 in the sequence bitmap of each k-pattern, set the corresponding position bitmap to 0, thereby obtaining the position bitmaps of all k-patterns.
[0366] Optionally, the second frequent pattern acquisition module 15 specifically includes:
[0367] A fourth calculation unit, used for calculating the support of each k-pattern according to the number of values 1 stored in the sequence bitmap of each k-pattern;
[0368] a fifth calculation unit, configured to accumulate the weights corresponding to the corresponding sequences for each sequence whose value is 1 in the sequence bitmap of each k-pattern, and divide the weights by the total weight of the sequence database to obtain the weighted support of each k-pattern;
[0369] A sixth calculation unit, used for calculating a comprehensive evaluation index according to the support and weighted support of each of the k-patterns;
[0370] The second determination unit is used to determine the k-pattern whose support is greater than or equal to a preset minimum support threshold, weighted support is greater than or equal to a preset minimum weight support threshold, and comprehensive evaluation index is greater than or equal to a preset minimum comprehensive score threshold as a high-weight frequent k-pattern.
[0371] Optionally, the comprehensive evaluation index is calculated according to the following formula:
[0372] score(k)=α*sup(k)+(1-α)*weiSup(k)
[0373] Where score(k) is the comprehensive evaluation index of the k-mode, α is a predefined parameter used to adjust the relative importance of support and weighted support, α∈[0,1], sup(k) is the support of the k-mode, and weiSup(k) is the weighted support of the k-mode.
[0374] Optionally, the device further comprises:
[0375] A first creation module is used to create a corresponding frequent item object according to each high-weight frequent 1-pattern, and add it to a pre-established high-weight frequent pattern set;
[0376] A second creation module is used to create a corresponding frequent item object according to each high-weight frequent k-pattern, and add it to the high-weight frequent pattern set;
[0377] Each frequent item object includes a pattern, support corresponding to the pattern, weighted support, comprehensive evaluation index, sequence bitmap and position bitmap.
[0378] Optionally, the device further comprises:
[0379] A confidence acquisition module, for acquiring the confidence of multiple sub-patterns from X to Y by using the weighted support in the high-weight frequent pattern set for the high-weight frequent k-pattern;
[0380] A weighted confidence matrix construction module, used to construct a weighted confidence matrix of the high-weighted frequent k-pattern according to the confidence of the multiple sub-patterns from X to Y;
[0381] The strong association identification module is used to identify strong association rules according to the weight confidence matrix.
[0382] Optionally, the confidence is calculated according to the following formula:
[0383] conf(X→Y)=weiSup(X∪Y) / weiSup(X)
[0384] Where conf(X→Y) represents the confidence from subpattern X to Y, weiSup(X∪Y) represents the weighted support of the union of subpatterns X and Y, weiSup(X) represents the weighted support of subpattern X, X and Y are non-empty subsequences of the high-weight frequent k-pattern, and
[0385] Optionally, if conf(X→Y) is not less than a preset minimum confidence threshold, it means that X and Y are strongly associated.
[0386] Embodiment 3:
[0387] refer to Figure 5 This embodiment provides a sequential pattern mining device, including a memory 21 and a processor 22. The memory 21 stores a computer program, and the processor 22 is configured to run the computer program to execute the sequential pattern mining method in Example 1.
[0388] The memory 21 is connected to the processor 22. The memory 21 may be a flash memory, a read-only memory or other memory. The processor 22 may be a central processing unit or a single-chip microcomputer.
[0389] Embodiment 4:
[0390] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the sequential pattern mining method in the above-mentioned embodiment 1 is implemented.
[0391] The computer-readable storage medium includes volatile or non-volatile, removable or non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, computer program modules or other data). Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable read only memory), flash memory or other memory technology, CD-ROM (Compact Disc Read-Only Memory), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer.
[0392] In summary, the sequential pattern mining method, device and readable storage medium provided by the embodiment of the present invention first calculate the binary sequence bitmap and position bitmap of each 1-pattern based on the sequence database; and calculate the high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database; then initialize k=2; then generate the sequence bitmap and position bitmap of all k-patterns according to the sequence bitmap and position bitmap of all high-weight frequent (k-1)-patterns; calculate the high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database; finally, determine whether k is equal to the preset pattern threshold, if so, end this process, if not, then Increase k by 1, and return to execute the steps of generating sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns. The present invention fully considers the weight differences between different sequences and can more accurately reflect the relative importance between them. At the same time, the present invention adopts innovative binary sequence bitmaps and position bitmaps to represent the positions where sequence data and patterns appear. This compact data structure not only significantly reduces storage overhead, but also makes it possible to achieve fast pattern matching through bit operations. Through the present invention, we can effectively mine sequence patterns that appear frequently and have high weights. These high-quality patterns will provide more reliable and valuable decision-making basis for various practical applications. It solves the problem that the existing sequence pattern mining methods mainly focus on the frequency of patterns and cannot fully reflect the true importance of patterns.
[0393] It is to be understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of the present invention, but the present invention is not limited thereto. For those of ordinary skill in the art, various modifications and improvements can be made without departing from the spirit and essence of the present invention, and these modifications and improvements are also considered to be within the scope of protection of the present invention.
Claims
1. A sequential pattern mining method, characterized in that: The method comprises: S1, calculate the sequence bitmap and position bitmap of each 1-pattern binary based on the sequence database; S2, calculating a high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database; S3, initialize k=2; S4, generating sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns; S5, calculating a high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database; S6, determining whether k is equal to a preset mode threshold, if so, ending the process, if not, increasing k by 1 and returning to step S4; The sequence bitmap indicates the specific position of each element in the pattern in the sequence containing the pattern, and the position bitmap indicates the specific position of each item in the pattern in the sequence containing the pattern.
2. The method according to claim 1, characterized in that The step of calculating the high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database specifically includes: Calculate the support of each 1-pattern according to the number of values 1 stored in the sequence bitmap of each 1-pattern; For each sequence whose value is 1 in the sequence bitmap of each 1-pattern, the weights corresponding to the corresponding sequences are accumulated and divided by the total weight of the sequence database to obtain the weighted support of each 1-pattern; Calculating a comprehensive evaluation index according to the support and weighted support of each of the 1-patterns; The 1-pattern whose support is greater than or equal to a preset minimum support threshold, whose weighted support is greater than or equal to a preset minimum weight support threshold, and whose comprehensive evaluation index is greater than or equal to a preset minimum comprehensive score threshold is determined as a high-weight frequent 1-pattern.
3. The method according to claim 1, characterized in that The step of generating the sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns specifically includes: Perform bitwise AND operation on the sequence bitmaps of any two high-weight frequent (k-1)-patterns among all high-weight frequent (k-1)-patterns to obtain the sequence bitmaps of all k-patterns; For each sequence whose value is 1 in the sequence bitmap of each of the k-patterns, obtain the position bitmaps of the sequences of two high-weight frequent (k-1)-patterns constituting the k-pattern, perform a bitwise OR operation on the two position bitmaps, and for each sequence whose value is 0 in the sequence bitmap of each of the k-patterns, set the corresponding position bitmap to 0, thereby obtaining the position bitmaps of all k-patterns.
4. The method according to claim 3, characterized in that The high-weight frequent k-pattern is obtained by calculating the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database, specifically including: Calculate the support of each k-pattern according to the number of values 1 stored in the sequence bitmap of each k-pattern; For each sequence whose value is 1 in the sequence bitmap of each k-pattern, the weights corresponding to the corresponding sequences are accumulated and divided by the total weight of the sequence database to obtain the weighted support of each k-pattern; Calculating a comprehensive evaluation index according to the support and weighted support of each of the k-patterns; The k-pattern whose support is greater than or equal to a preset minimum support threshold, whose weighted support is greater than or equal to a preset minimum weight support threshold, and whose comprehensive evaluation index is greater than or equal to a preset minimum comprehensive score threshold is determined as a high-weight frequent k-pattern.
5. The method according to claim 4, characterized in that The comprehensive evaluation index is calculated according to the following formula: score(k)=α*sup(k)+(1-α)*weiSup(k) Where score(k) is the comprehensive evaluation index of the k-mode, α is a predefined parameter used to adjust the relative importance of support and weighted support, α∈[0,1], sup(k) is the support of the k-mode, and weiSup(k) is the weighted support of the k-mode.
6. The method according to claim 1, characterized in that The method further comprises: Create a corresponding frequent item object according to each high-weight frequent 1-pattern and add it to the pre-established high-weight frequent pattern set; Creating a corresponding frequent item object according to each high-weight frequent k-pattern, and adding it to the high-weight frequent pattern set; Each frequent item object includes a pattern, support corresponding to the pattern, weighted support, comprehensive evaluation index, sequence bitmap and position bitmap.
7. The method according to claim 6, characterized in that After obtaining the high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database, the method further includes: For the high-weight frequent k-pattern, using the weighted support in the high-weight frequent pattern set, obtain the confidence of multiple sub-patterns from X to Y; Constructing a weighted confidence matrix of the high-weight frequent k-pattern according to the confidences of the multiple sub-patterns from X to Y; Strong association rules are identified based on the weight confidence matrix.
8. The method according to claim 7, characterized in that The confidence level is calculated according to the following formula: conf(X→Y)=weiSup(X∪Y) / weiSup(X) Where conf(X→Y) represents the confidence from subpattern X to Y, weiSup(X∪Y) represents the weighted support of the union of subpatterns X and Y, weiSup(X) represents the weighted support of subpattern X, X and Y are non-empty subsequences of the high-weight frequent k-pattern, and 9. The method according to claim 8, characterized in that If conf(X→Y) is not less than the preset minimum confidence threshold, it means that X and Y are strongly associated.
10. A sequential pattern mining device, characterized in that: The device comprises: A first bitmap calculation module, used for calculating a sequence bitmap and a position bitmap of each 1-mode binary based on a sequence database; A first frequent pattern acquisition module, connected to the first bitmap calculation module, is used to calculate and obtain a high-weight frequent 1-pattern according to the sequence bitmap of each 1-pattern and the weight of the corresponding sequence in the sequence database; an initialization module, connected to the first frequent pattern acquisition module, and used to initialize k=2; A second bitmap calculation module, connected to the initialization module, is used to generate sequence bitmaps and position bitmaps of all k-patterns according to the sequence bitmaps and position bitmaps of all high-weight frequent (k-1)-patterns; A second frequent pattern acquisition module, connected to the second bitmap calculation module, is used to calculate and obtain a high-weight frequent k-pattern according to the sequence bitmap of each k-pattern and the weight of the corresponding sequence in the sequence database; an iterative judgment module, connected to the second frequent pattern acquisition module, for judging whether k is equal to a preset pattern threshold, if so, terminating the process, if not, increasing k by 1, returning to and executing the second bitmap calculation module; The sequence bitmap indicates the specific position of each element in the pattern in the sequence containing the pattern, and the position bitmap indicates the specific position of each item in the pattern in the sequence containing the pattern.
11. A sequential pattern mining device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to implement the sequence pattern mining method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the sequential pattern mining method according to any one of claims 1 to 9 is implemented.