Frequency counts how often an item occurs within a specified dataset. The unit being counted matters: in transaction data, an item's support count is the number of invoices containing it; in bag-of-words text data, a word's frequency is its count in a sentence or document. section 4.5 section 7.9
For transaction analysis, start by finding the invoices containing each item. Then find invoices containing each candidate pair or larger itemset. Counting those invoices gives the support count used to decide which combinations meet a chosen minimum. section 4.5
Count purchases, then set a threshold
Eggs occur in all five invoices, while milk occurs in two. Eggs and bread occur together in four invoices; milk and cheese never occur together. With a minimum support count of three, {eggs, bread} is the only qualifying combination in this example. Lowering the minimum to two admits more combinations. section 4.5
Frequency also determines the initial item order for an F-P tree. Scan all transactions, count the transactions containing each item, and sort items by descending support count; equal counts can appear in either order. As transactions are added to the tree, counts on existing nodes increase and new branches are created where needed. section 4.6
Table 4.8 Respective frequency for each of the item sets
|
Item
|
Frequency or support count
|
|---|---|
|
Milk
|
7
|
|
Apples
|
6
|
|
Bread
|
6
|
|
Cheese
|
2
|
|
Eggs
|
2
|
Compare the counts before tree construction: milk appears in seven of nine transactions, apples and bread in six each, and cheese and eggs in two each. section 4.6
For bag-of-words representation, tokenize the text and define a vocabulary from the corpus's unique words. Give each sentence or document one vector position per vocabulary word. Fill each position with that word's frequency in the text, or zero if it is absent. Upper and lower frequency limits can restrict which words enter the vocabulary. section 7.9
Represent a sentence by word counts
With “It is raining heavily” and “We should eat fruits” as the corpus, form a vocabulary from their words. The first sentence's vector records its own word counts and assigns zero to words appearing only in the second sentence. This is a simple, computationally inexpensive representation for tasks such as document classification, but it discards word order, grammar, and context; that loss can hurt accuracy. section 7.9






