liveBook · Manning

Frequency

As explained in Data Without Labels

Frequency is the number of times an item such as a word or token occurs in a specified text or collection.

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

How Data Without Labels covers it

How deep it goes
Works through invoice counts, F-P tree updates, and word-count vectors, without developing a general mathematical theory of frequency.
Examples
Counts items across five invoices and nine transactions, then counts words in two sentences.
What it assumes
Introduces tokenization and vocabulary through sentences while explaining transaction counts through invoice lists.
What you can do after
Build it from scratch: count occurrences to filter transaction combinations, order F-P tree items, or construct bag-of-words vectors.
How it connects
Connects support count and minimum-support thresholds with ECLAT and F-P trees, and token frequency with vocabularies and document classification.

Also explained in

Compare how 7 books explain frequency →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Without Labels. The section links point to the parts of the book it draws on.