Mining the Top-K High-Utility Itemsets in a Data Stream using the FHMDS Algorithm (SPMF documentation)

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

How to run this example?

What is FHMDS?

FHMDS (Dawar et al., 2017) is an algorithm for discovering high-utility itemsets in a data stream of transactions containing utility information.

High utility itemset mining has several applications such as discovering groups of items in transactions of a store that generate the most profit. A database containing utility information is a database where items can have quantities and a unit price. Although these algorithms are often presented in the context of market basket analysis, there exist other applications.

Unlike some other high utility itemset mining algorithm, the FHMDS algorithms processes transactions by batch. For each batch, FHMDS outputs the top-k itemsets having the highest utility (e.g. profit).

What is the input?

FHMDS takes as input a transaction database with utility information, a parameter k (a positive integer), a parameter window_size (positive integer), and a parameter transactions/batch (positive integer).

Let's consider the following database consisting of 5 transactions (t1,t2...t5) and 7 items (1, 2, 3, 4, 5, 6, 7). This database is provided in the text file "DB_utility.txt" in the package ca.pfv.spmf.tests of the SPMF distribution.


Items Transaction utility Item utilities for this transaction
t1 3 5 1 2 4 6 30 1 3 5 10 6 5
t2 3 5 2 4 20 3 3 8 6
t3 3 1 4 8 1 5 2
t4 3 5 1 7 27 6 6 10 5
t5 3 5 2 7 11 2 3 4 2

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 3, 5, 1, 2, 4 and 6. The amount of money spent for each item is respectively 1 $, 3 $, 5 $, 10 $, 6 $ and 5 $. The total amount of money spent in this transaction is 1 + 3 + 5 + 10 + 6 + 5 = 30 $.

What is the output?

The output of FHDMS is the top-k high utility itemsets for each batch of transactions, that is the k itemsets that have the highest utility in each batch of transaction for the database taken as input.

The database of the above example contains five transactions, and transactions/batch is set to 2 in this example. Thus, the algorithm will process two batch of transactions. The first batch of transactions is:


Items Transaction utility Item utilities for this transaction
t1 3 5 1 2 4 6 30 1 3 5 10 6 5
t2 3 5 2 4 20 3 3 8 6

The second batch of transactions is:


Items Transaction utility Item utilities for this transaction
t3 3 1 4 8 1 5 2
t4 3 5 1 7 27 6 6 10 5

To explain what is a top-k high utility itemset, it is necessary to review some definitions. An itemset is an unordered set of distinct items. 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 {1 4} in transaction t1 is 5 + 6 = 11 and the utility of {1 4} in transaction t3 is 5 + 2 = 7. The utility of an itemset in a batch of transactions is the sum of its utility in all transactions where it appears. For example, the utility of {1 4} in the first batch of transaction is the utility of {1 4} in t1 plus the utility of {1 4} in t2, for a total of 11 + 0 = 11. The top-k high utility itemsets is the set of the k itemsets that have the highest utility in each batch. It is to be noted that in some cases, it is possible that the algorithm returns more than k itemsets if several itemsets have the same utility.

In the example, the top-5 high utility itemsets in the first batch of transactions are:

itemsets utility
{1 3 5} 31
{2 3 4} 34
{2 4 5} 36
{2 3 4 5} 36
{1 2 3 4 5 6} 30

In the example, the top-5 high utility itemsets for the second batch of transactions are:

itemsets utility
{1 3 5 7} 27
{1 3 5} 22
{1 3} 22
{1 5 7} 21
{1 3 5} 21

If the database is a transaction database from a store, we could interpret these results as the five set of items that generated the most money for different batch of customer transactions.

Note that the FMDS algorithms also apply a window constraint to find the above results. For the meaning of the window constraint, please see the reference paper for the FMDS algorithm.

Input file format

The input file format of FHMDS is defined as follows. It is a text file. Each lines represents a transaction. Each line is composed of three sections, as follows.

For example, for the previous example, the input file is defined as follows:

3 5 1 2 4 6:30:1 3 5 10 6 5
3 5 2 4:20:3 3 8 6
3 1 4:8:1 5 2
3 5 1 7:27:6 6 10 5
3 5 2 7:11:2 3 4 2

Consider the first line. It means that the transaction {3, 5, 1, 2, 4, 6} has a total utility of 30 and that items 3, 5, 1, 2, 4 and 6 respectively have a utility of 1, 3, 5, 10, 6 and 5 in this transaction. The following lines follow the same format.

Output file format

The output file format of FHMDS is defined as follows. It is a text file, where each line represents a 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 of the itemset (a float). Between the results of each batch, a line "@NEXT_BATCH" is added. For example, we show below the output file for this example.

1 5 3 #UTIL: 31.0
2 4 5 3 #UTIL: 40.0
2 4 5 #UTIL: 36.0
2 4 3 #UTIL: 34.0
6 2 4 1 5 3 #UTIL: 30.0
@NEXT_BATCH
7 1 5 3 #UTIL: 27.0
1 5 3 #UTIL: 22.0
1 3 #UTIL: 22.0
7 1 5 #UTIL: 21.0
7 1 3 #UTIL: 21.0

For example, the first line indicates that the itemset {1, 3, 5} has a utility of 31 in the first batch. The following lines follows the same format.

Performance

High utility itemset mining is a more difficult problem than frequent itemset mining. Therefore, high-utility itemset mining algorithms are generally slower than frequent itemset mining algorithms.

The FHMDS algorithm is an efficient algorithm for discovering the top-k patterns in a data stream when transactions are processed by batch.

Implementation details

The version offered in SPMF is the original implementation of FHMDS.

Note that a naive version of FHMDS is also offered in SPMF called FHMDSNaive. See the paper about FHMDS for details about the naive version.

Note that the input format is not exactly the same as described in the article. But it is equivalent.

Where can I get more information about the FHMDS algorithm?

This is the reference of the article describing the FHMDS algorithm:

Siddharth Dawar, Veronica Sharma, Vikram Goyal: Mining top-k high-utility itemsets from a data stream under sliding window model. Appl. Intell. 47(4): 1240-1255 (2017)

For a good overview of itemset mining algorithms, you may read this survey paper.