Mining Local High-Utility Itemsets in a Transaction Database using the LHUI-Miner Algorithm (SPMF documentation)

This example explains how to run the LHUI-Miner algorithm using the SPMF open-source data mining library.

How to run this example?

What is LTHUI-Miner?

LHUI-Miner (Fournier-Viger, P. Zhang, Y et al, 2019) is an algorithm for discovering local high-utility itemsets in a transaction database containing utility information and timestamps

LHUI-Miner is an algorithm that extends the HUI-Miner algorithm to mine local high utility itemsets (LHUI). An itemset is said to be a LHUI if there are some time periods where the itemset has a high utility. For example, the algorithm could be use to find time periods where products yield a lot of money in a customer transaction database. To find local high utility itemsets, period information is added to traditional utility-lists, and the algorithm uses a sliding window technique to explore each itemset’s utility-list to determine if it is a LHUI.

What is the input?

LHUI-Miner takes as input a transaction database with utility values and the lMinutil and minLength thresholds. 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_LHUI.txt" in the package ca.pfv.spmf.tests of the SPMF distribution

Items

Transaction utility

Item utilities for this transaction

Timestamp

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

Each line of the database is:

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 LHUI-Miner is the set of local high utility itemsets having at least one window (time period) of length minLength during which it generate utility no less than a min_utility threshold. To explain what is a local 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 generate utility greater than lMin_util. For example, if we run LHUI-Miner with a minLength of 3 and lMin_util of 40, we obtain 14 high-utility itemsets:


itemsets

utility

LHUI periods

{4 2}

66

[3,5]

{4 2 1}

50

[5,5]

{4 2 1 5}

56

[5,5]

{4 2 1 5 3}

58

[5,5]

{4 2 5}

78

[3,5]

{4 2 5 3}

85

[3,5]

{4 2 3}

73

[3,5]

{4 5}

46

[3,5]

{4 5 3}

53

[3,5]

{4 3}

47

[3,5]

{1 3 5} 62 [5,6]

{2 5}

62

[3,5]

{2 5 3}

74

[3,7]

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). Note that the LHUI period is the time periods when the itemsets have high utility.

Input file format

The input file format of LHUI-Miner is defined as follows. It is a text file. Each line represents a transaction. Each line is composed of four sections, as follows.

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 LHUI-Miner is defined as follows. It is a text file, where each line represents a local 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 LHUI periods. For example, we show below the output file for this example.

4 1 2 #UTIL: 50 [5,5]
4 1 2 5 #UTIL: 56 [5,5]
4 1 2 5 3 #UTIL: 58 [5,5]
4 1 2 3 #UTIL: 52 [5,5]
4 2 #UTIL: 66 [3,5]
4 2 5 #UTIL: 78 [3,5]
4 2 5 3 #UTIL: 85 [3,5]
4 2 3 #UTIL: 73 [3,5]
4 5 #UTIL: 46 [3,5]
4 5 3 #UTIL: 53 [3,5]
4 3 #UTIL: 47 [3,5]
1 5 3 #UTIL: 62 [5,6]
2 5 #UTIL: 62 [3,5]
2 5 3 #UTIL: 74 [3,7]

For example, the first line indicates that the itemset {2, 4} is a LHUI and its utility in the whole database is 66. The itemset’s LHUI period is [3,5]. The following lines follows the same format.

Performance

Local high utility itemset mining can find patterns that are ignored by traditional high utility itemset mining algorithms and thus is a more difficult problem than traditional high utility itemset mining. Therefore, local high-utility itemset mining algorithms are generally slower than high uility itemset mining algorithms when the average utility of the two algorithms are equal. However, when the number of patterns are similar, LHUI-Miner’s performance is similar to that of HUI-Miner.

Implementation details

The version implemented here contains all the optimizations described in the paper proposing LTHUI-Miner. Note that the input format is not exactly the same as described in the original article. But it is equivalent.

Where can I get more information about the LHUI-Miner algorithm?

This is the reference of the article describing the LHUI-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.