Association Mining
Covers frequent itemset mining and association rule generation, including support, confidence, and interest metrics, along with efficient algorithms: A-Priori, PCY, Multi-Stage, Multi-Hash, and SON for distributed datasets.
Association mining is the problem of finding a mapping between many to many kinds of things
Frequent itemsets
We want to find a set of items that appear together frequently in baskets. We have a defined support threshold which we use to determine when items are to be considered. The sets of items that appear in at least s baskets are called frequent itemsets

Association rules
they are if-then rules about the contents of baskets , this means "if a basket contains all of then it is likely to contain ". The Confidence of this association rule is the probability of given , defined as:
Not all high confidence rules are interesting. let's take an item that is very often bought, let's call this FreqItem, then is not very useful because the confidence will be high regardless of what is
The Interest of an association rule is the absolute difference between its confidence and the probability that a basket contains
We could call a rule interesting if they have high interest values (usually above 0.5)

Finding association rules
We want to find all association rules with and If has high support and confidence, then both and will be "frequent"
We find all frequent itemsets , then for every subset of , generate the rule . Since is frequent, is also frequent
(variant 1): Single pass to compute the rule confidence:
(variant 2): we know that if is below confidence, then is also below confidence. This means we can generate bigger rules from smaller ones
Given items, there are a total of possible itemsets
We can reduce the number of rules by post processing them and output only:
- Maximal Frequent Itemset: A frequent item set X is maximal if the , and no superset of it is frequent. (we get the set of items which is the largest set that we can get without dropping below the threshold, as in, any element that we add to this set will make it drop below the )
- Closed item sets: An itemset is closed if none of it's supersets have the exact same support as . (adding any item to this item set will reduce it's support)
Computation issues with finding frequent itemsets
To be able to compute the frequent itemsets we need to be able to read the whole items, this means having a way to read all the different items in the set. In large datasets this information is stored in disk, and the majority of time of the computation will be in disk I/O We can think of items being part of baskets, where baskets are files in disk
The hardest problem is finding frequent pairs of items , as it's the most likely. the probability of items to be frequent drops exponentially with the size of the set.
Naive algorithm
A naive approach to find frequent pairs is to read the file once, counting in main memory the occurrences of each pair. From each "basket" of items, generate it's pairs by using two nested loops. This approach fails if the exceeds the main memory. There are two approaches to this:
- Count all pairs using a matrix, but this combinations between pairs (4 bytes, aka 1 number), this generates a triangular matrix, following the 2 loops
- Keep a table of triples which means "the count of the pair items is c", but this is stored only if the (12 bytes, 1 number and 2 Ids)
With the first approach, the total number of pairs is , the second approach is better only if less than 1/3rd of the possible pairs occur
A-Priori Algorithm
Instead of doing a single pass, we use a two pass approach that uses the idea of monotonicity. Monotonicity applies because if a set of itemset appears at least times, so does every subset of . And for pairs, if item does not appear in baskets, then no pair including can appear in baskets As mentioned the algorithm works in two passes
- Read baskets and count in main memory the occurrences of each item. Items that times are frequent items
- Read the baskets again and count in main memory only the pairs where both elements are considered frequent from pass 1
This approach uses as much memory as the square of frequent items plus a list of the frequent items

When dealing with frequent triples or higher, let's say (a set of size ), we then define:
- as the candidate whose support might be based off the pass.
- as the set of truly frequent

PCY (Park-Chen-Yu) Algorithm
We observe that in the first pass of the algorithm, most memory is idle.
The PCY algorithm uses the intuition that:
instead of getting the counts of each item in the dataset, we counted the number of items that started with each letter of the alphabet. If the number of items that started with the letter ‘a’ was less than our support threshold, we would know that none of the items that start with the letter ‘a’ are frequent. For example, if apples had been frequent, then the count of items starting with ‘a’ would have been above our threshold.
The PCY algorithm uses the unused memory to store a hashtable with as many buckets as fit in the unused memory, and in this hashtable, it stores the count of the hash of every combination of items inside of the basket, and increments it by 1 if it already exists. Once finished with this first step, we know that all the hashed pairs in the hashtable which are below the support must not be frequent, else the items would have hashed to those buckets, so we know that any pair that hashes to a bucket with support lower than is surely not a frequent pair. link to explaination
this means that we can eliminate all candidates of items that hash to buckets which are below the support.
In the second pass of the algorithm, we count only pairs that hash to frequent buckets. We could simplify this hashmap by changing it from storing buckets of integers, to storing a bucket of bits, with value 1 if the bucket is frequent, and value 0 if the bucket is not frequent

In general the condition for an element to be considered frequent, is that in a pair:
- both are frequent
- the pair hashes to a frequent bucket
Multi stage algorithm
This is a refinement of the PCY algorithm, in cases where memory is still a bottleneck, we can do 3 passes over the data. the first step is the same as the PCY algorithm, the second step, we rehash only the values that qualify for pass 2 of PCY (so that are frequent and the bucket is frequent)
And in this case, a pair is considered frequent if:
- both are frequent items
- Using the first hash function, the pair hashes to a frequent bucket
- Using the second hash function, the pair hashes to a frequent bucket
It is important that the two hashing functions are independent from each other
Multi hash
We can also use multiple hashing functions in multiple hashing tables in the first stage, the problem with this approach is that every time we increase the number of hashing steps, we lower the amount of buckets, increasing the average count of a pair being in a bucket
SON algorithm
This is especially useful in distributed dataset scenario, and the dataset is impossible to be stored on a single machine.
- Each machine gets a partition of the data that it can fit in memory
- Each machine applies one of the frequent itemset mining algorithms independently to each partition. The support is the same between each machine
- Combine all the frequent item sets from all partitions to generate a set of candidate global frequent itemsets
- Verify the global frequent itemsets in the entire dataset to determine the truly frequent itemsets