June 2020
Intermediate to advanced
382 pages
11h 39m
English
Let's consider the transaction data shown in the following table. Let's first represent it as a sparse matrix:
| ID | Bat | Wickets | Pads | Helmet | Ball |
| 1 | 0 | 1 | 1 | 0 | 0 |
| 2 | 1 | 1 | 1 | 1 | 0 |
| 3 | 0 | 0 | 0 | 1 | 1 |
| 4 | 1 | 0 | 1 | 1 | 0 |
Let's calculate the frequency of each item and sort them in descending order by frequency:
| Item | Frequency |
| pads | 3 |
| helmet | 3 |
| bat | 2 |
| wicket | 2 |
| ball | 1 |
Now let's rearrange the transaction-based data based on the frequency:
| ID | Original Items | Reordered Items |
| t1 | Wickets, pads | Pads, wickets |
| t2 | Bat, wickets, pads, helmet | Helmet, pads, wickets, bat |
| t3 | Helmet, ball | Helmet, ball |
| t4 | Bat, pads, helmet | Helmet, pads, bat |
To build the FP-tree, let's start with the first branch of the FP-tree. The FP-tree ...