Improve the quality of dataAlgorithmValidity
Major challenges:
1. scan data multiple times
2. A large number of candidate sets will be generated
3. The calculation of support for candidate item sets is cumbersome.
Solution
1. reduce data scanning
2. Reduce the candidate item set
3. Improved the calculation method for the support of candidate item sets
Method 1: Count item Sets Based on Hash Tables
Map each item set to different buckets in the hash table through the corresponding hash function. In this way, the item set count in the bucket can be compared with the minimum support count, and a part of the item set can be eliminated first.
(Delete the entire bucket)
Method 2: compress transactions (compress the number of transactions for further iteration)
Transactions that do not contain any k-item set cannot contain any (k + 1) item set. Such transactions can be marked or deleted in the next calculation.
Method 3: Division
Only two data scans are required to mine frequent item sets.
Any frequent item set in D must appear in at least one part as a local frequent item set.
First scan: divide the data into multiple parts and find the local frequent item set
Second scan: evaluate the actual support of each candidate item set to determine the global frequent item set.
Method 4: sample selection (mining a subset of given data)
Basic Idea: select a sample of the original data and use the Apriori algorithm to mine frequent patterns on this sample.
The algorithm overhead is reduced by sacrificing accuracy. To improve efficiency, the sample size should be suitable in the memory, and the minimum support can be appropriately reduced to reduce the frequent pattern omissions.
A global scan can be used to verify the pattern found from the sample.
You can find the missing mode through the second global scan.
Method 5: Dynamic item set count
Add a candidate item set at different points of scanning. In this way, if a candidate item set already meets the minimum support, you can directly add it to the frequent item set, you do not need to continue computing in the future comparison of this scan.
Build a FP tree from the database
The main overhead of the Apriori algorithm:
A large number of candidate item sets may be generated
(10, 4) Frequent 1-item set lead to (10, 7) Frequent 2-item set
For a frequent pattern with a length of 100, (2,100) candidates will be generated.
Scan the database repeatedly and check a large set of candidates through pattern matching.
Algorithms without generating candidate frequent item sets-FP tree frequency Set Algorithms
A method using divide and conquer
After the first scan, the database's frequency set is compressed into a frequent mode tree (FP-tree), and the associated information is retained.
Divide the FP-tree into several condition libraries, each of which is related to a frequency set with a length of 1, and then mine these condition libraries separately.
Build a FP tree from the database
Steps:
1. Scan the database once and export the set of frequent Items (1-item set)
2. Sort frequent items in descending order
3. Scan the database again to build the FP tree
FP tree Mining
1. Create the root node of the tree and mark it with null
2. Sort the items in each transaction by descending support count, and create a branch for each transaction
3. When adding a branch for a transaction, the Count of each node along the common prefix is + 1, creating a node for the item following the prefix and connecting
For example, when the second transaction {f, C, A, B, m} is added to the tree, it is F, C, and a each increases by 1, and then {B, m} create Branch
4. Create an item header table to facilitate traversal. Each item points to it in the tree through a node chain.
Step for FP tree mining:
Starts from the frequent mode with a length of 1 (initial suffix mode) and constructs its conditional mode base (a "sub-database ", the prefix path set in the FP tree and in the suffix mode)
Construct the conditional FP tree for the initial suffix mode and implement recursive mining on the tree. Mode growth is achieved through frequent mode connections between the suffix mode and the conditional FP tree.