Mining Peak High-Utility Itemsets in a Transaction Database using the PHUI-Miner Algorithm (SPMF documentation)
This example explains how to run the PHUI-Miner algorithm using the SPMF open-source data mining library.
How to run this example?
- If you are using the graphical interface, (1) choose the "PHUI-Miner" algorithm, (2) select the input file "DB_LHUI.txt", (3) set the output file name (e.g. "output.txt") (4) set the local minimum utility to 40, the window length to 3, lambda to 2 and (5) click "Run algorithm".
- If you want to execute this example from the command line,
then execute this command:
java -jar spmf.jar run PHUI-Miner DB_LHUI.txt output.txt 40 3 2 in a folder containing spmf.jar and the example input file DB_LHUI.txt. - If you are using the source code version of SPMF, launch the file "MainTestPHUIMiner.java" in the package ca.pfv.SPMF.tests.
What is HUI-Miner?
PHUI-Miner (Fournier-Viger, P. Zhang, Y et al, 2019) is an algorithm for discovering peak high-utility itemsets in a transaction database containing utility information and timestamps. A peak high utility itemset is a set of items that yield a utility that is unusually high during a time periods. For example, this algorithm can be used to find time periods where some prodcuts are sold together and yield a unusual profit, such as selling pens and notebooks during the back to school shopping season..
PHUI-Miner is an algorithm that extends the LHUI-Miner algorithm to mine peak high utility itemset (PHUI). An itemset is said to be a PHUI if 1) the itemset is a local high utility itemset (LHUI) and 2) there is at least one peak window (a peak is defined using the concept of moving average crossover). To achieve this goal, the periods information is added to traditional utility-list data structure. To detect the peak time periods, the algorithm uses two sliding windows (of different length) to explore each itemset’s utility-list to determine if it is a PHUI
What is the input?
PHUI-Miner takes as input a transaction database with utility values and the lMinutil, minLength and parameter lambda.. Let's consider the following database consisting of 8 transactions (t1,t2...t8) and 5 items (1, 2, 3, 4, 5), and each transaction is associated with a timestamp. This database is provided in the text file "DB_utility_time.txt" in the package ca.pfv.spmf.tests of the SPMF distribution.
Items |
Transaction utility |
Item utilities for this transaction |
Timestamp |
|
t1 |
2 3 5 |
9 |
4 2 3 |
1 |
t2 |
2 3 4 5 |
18 |
8 3 4 3 |
3 |
t3 |
2 3 4 5 |
9 |
4 2 10 3 |
3 |
t4 |
1 2 3 4 5 |
58 |
10 20 2 20 6 |
5 |
t5 |
1 3 5 |
22 |
10 6 6 |
6 |
t6 |
2 3 5 |
14 |
8 3 3 |
7 |
t7 |
1 3 4 |
16 |
10 2 4 |
9 |
t8 |
1 3 5 |
22 |
10 6 6 |
10 |
Each line of the database is:
- a set of items (the first column of the table),
- the sum of the utilities (e.g. profit) of these items in this transaction (the second column of the table),
- the utility of each item for this transaction (e.g. profit generated by this item for this transaction)(the third column of the table).
- the timestamp which indicated when this transaction was made(the fourth column of the table)
Note that the value in the second column for each line is the sum of the values in the third column.
What are real-life examples of such a database? There are several applications in real life. One application is a customer transaction database. Imagine that each transaction represents the items purchased by a customer. The first customer named "t1" bought items 2, 3 and 5. The amount of money spent for each item is respectively 4 $, 2 $ and 3 $. The total amount of money spent in this transaction is 4 + 2 + 3 = 9 $. And the purchase was made in time 1.
What is the output?
The output of PHUI-Miner is the set of peak high utility itemsets with their peak windows. A peak high utility itemset must be a local high utility itemset. To explain what is a peak high utility itemset, it is necessary to review some definitions. An itemset is an unordered set of distinct items. And a window is the set of transactions which were made during the given time period. For example, window w(1,3) is the set transactions that were made during time 1 to 3, i.e. w(1,3)={t1,t2,t3}. The utility of an itemset in a transaction is the sum of the utility of its items in the transaction. For example, the utility of the itemset {2 3} in transaction t1 is 4 + 2 = 6 and the utility of {2 3} in transaction t2 is 8 + 3 = 11. The utility of an itemset in a window is the sum of the utility of its items in the transactions in the window. For example, the utility of the itemset {2 3} in window w(1,3) is the sum of itemset {2 3} in t1, t2 and t3, i.e. (4+2)+(8+3)+(4+2)=35. The utility of an itemset in a database is the sum of its utility in all transactions where it appears. A local high utility itemset is an itemset such that there exists at least one window of length minLength during which the itemset generates autility greater than lMin_util. And a window is called a peak window of a local high utility itemset if for every time point in the window, the moving average utility of window of length lMin_util is greater than the moving average utility of length lMin_util x lambda For example, if we run PHUI-Miner with a minLength of 3, lMin_util of 40 and lambda of 2, we obtain 9 peak high-utility itemsets with their peak window(s):
itemsets |
utility |
Peak windows |
{ 4 3 } |
47 |
[5,5] |
{ 2 5 } |
62 |
[5,5] |
{ 4 5 } |
46 |
[5,5] |
{ 2 4 } |
66 |
[5,5] |
{ 2 4 3 } |
73 |
[5,5] |
{ 2 4 3 5 } |
85 |
[5,5] |
{ 2 4 5 } |
78 |
[5,5] |
{ 2 3 5 } |
74 |
[5,7] |
{ 4 3 5 } |
53 |
[5,5] |
If the database is a transaction database from a store, we could interpret these results as all the groups of items bought together that generated a profit of 40 $ or more in a short period (e.g. 3 days), and they have a profit peak during these windows.
Input file format
The input file format of PHUI-Miner is defined as follows. It is a text file. Each line represents a transaction. Each line is composed of four sections, as follows.
- First, the items contained in the transaction are listed. An item is represented by a positive integer. Each item is separated from the next item by a single space. It is assumed that all items within a same transaction (line) are sorted according to a total order (e.g. ascending order) and that no item can appear twice within the same transaction.
- Second, the symbol ":" appears and is followed by the transaction utility (an integer).
- Third, the symbol ":" appears and is followed by the utility of each item in this transaction (an integer), separated by single spaces.
- Fourth, the symbol ":" appears and is followed by the timestamp (an integer) indicating when the transaction were made.
For example, for the previous example, the input file is defined as follows:
2 3 5:9:4 2 3:1
2 3 4 5:18:8 3 4 3:3
2 3 4 5:9:4 2 10 3:3
1 2 3 4 5:58:10 20 2 20 6:5
1 3 5:22:10 6 6:6
2 3 5:14:8 3 3:7
1 3 4:16:10 2 4:9
1 3 5:22:10 6 6:10
Consider the first line. It means that the transaction {2, 3, 5} has a total utility of 9 and that items 2, 3 and 5 respectively have a utility of 4, 2 and 3 in this transaction, and the transaction were made at time 1. The following lines follow the same format.
Output file format
The output file format of PHUI-Miner is defined as follows. It is a text file, where each line represents a peak high utility itemset. On each line, the items of the itemset are first listed. Each item is represented by an integer, followed by a single space. After, all the items, the keyword " #UTIL: " appears and is followed by the utility (in the whole database) of the itemset. Then, it is followed by the itemset’s peak windows. For example, we show below the output file for this example.
2 3 4 #UTIL: 73 peak windows: [5,5]
2 3 4 5 #UTIL: 85 peak windows: [5,5]
2 3 5 #UTIL: 74 peak windows: [5,7]
2 4 #UTIL: 66 peak windows: [5,5]
2 4 5 #UTIL: 78 peak windows: [5,5]
2 5 #UTIL: 62 peak windows: [5,5]
3 4 #UTIL: 47 peak windows: [5,5]
3 4 5 #UTIL: 53 peak windows: [5,5]
4 5 #UTIL: 46 peak windows: [5,5]
For example, the first line indicates that the itemset {2, 4} is a PHUI and its utility in the whole database is 66. The itemset’s peak window is [5,5]. The following lines follows the same format.
Performance
PHUI-Miner needs to using two sliding windows to identify the peak windows and thus is generally slower than LHUI-Miner. And they both are much slower than HUI-Miner in most cases since they find more patterns for comparable parameter settings. But if the number of patterns found by PHUI-Miner is similar to HUI-Miner, the performance of two algorithms are similar.
Implementation details
In this version of PHUI-Miner, we use a smaller second windows and standard moving average (not center moving average as described in paper). Because the example database is small, the result can be different using different implementation. However, when using the real world database, the result will be almost same.
Where can I get more information about the PHUI-Miner algorithm?
This is the reference of the article describing the PHUI-Miner algorithm:
Fournier-Viger, P., Zhang, Y., Lin, J. C.W., Fujita, H., Koh, Y.S. (2019). Mining Local and Peak High Utility Itemsets. Information Sciences, Elsevier, 481: 344-367.
Besides, for a general overview of high utility itemset mining, you may read this survey paper.