Mining Locally Trending High-Utility Itemsets in a Transaction Database using the LTHUI-Miner Algorithm (SPMF documentation)

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

How to run this example?

What is LHUI-Miner?

LTHUI-Miner (Fournier-Viger, P. Yang, Y et al, 2020) is an algorithm for discovering locally trending high-utility itemsets in a transaction database containing utility information and timestamps

LTHUI-Miner is an algorithm that extends the HUI-Miner algorithm to mine locally trending high utility itemsets (LTHUI). An itemset is said to be a LTHUI if there are some time periods where the itemset has a high utility and the utility follows an upward or downward trend. For example, the algorithm could be used to find time periods where products yield a lot of money and the money shows an increasing trend in a customer transaction database. To find locally trending high utility itemsets, the algorithm uses the concept of bins and sliding windows to explore each itemset’s utility-list to determine if it is a LTHUI, and period information and bin information are added to traditional utility-lists.

What is the input?

LTHUI-Miner takes as input a transaction database with utility values and timestamps and the lminutil, winlen, binlen and minslope (indicating an increasing trend) thresholds.

Let's consider the following database consisting of 9 transactions (t1,t2...t9) 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_LTHUI.txt" in the package ca.pfv.spmf.tests of the SPMF distribution


Transaction Utility

Item utilities for this transaction


2 3 5


4 2 3


2 3 4 5


8 3 4 3


2 3 5


10 1 3


1 2 3


10 20 2


1 3 5


10 6 6


2 3


8 3


2 3


32 2


1 3 5


10 6 6


2 3 5


10 2 3


Each line of the database is:

  1. a set of items (the first column of the table),
  2. the sum of the utilities (e.g. profit) of these items in this transaction (the second column of the table),
  3. the utility of each item for this transaction (e.g. profit generated by this item for this transaction)(the third column of the table).
  4. 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 LTHUI-Miner is the set of locally trending high utility itemsets having at least one sliding window (time period) of length winlen during which it generates utility no less than a lminutil threshold and the statistical slope of utility is no less than a minslope threshold. To explain what is a locally trending 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)+(10+1)=28. The utility of an itemset in a database is the sum of its utility in all transactions where it appears.

A locally trending high utility itemset is an itemset such that there exists at least one sliding window of length winlen during which the itemset generate utility greater than lminutil and the statistical slope of utility is no less than a minslope threshold. For example, if we run LTHUI-Miner with a lminutil of 20, a winlen of 9, a binlen of 3, and a minslope of 5, we obtain 2 locally trending high-utility itemsets:


LTHUI periods




[1, 9]



{2, 3}

[1, 9]



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 20 $ or more in a time period (e.g. 9 days) and the profit. Note that the LHUI period is the time periods when the itemsets have high utility.

Input file format

The input file format of LTHUI-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 5:14:10 1 3:4
1 2 3:32:10 20 2:4
1 3 5:22:10 6 6:6
2 3:11:8 3:7
2 3:34:32 2:9
1 3 5:22:10 6 6:10
2 3 5:15:10 2 3:12

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 LTHUI-Miner is defined as follows. It is a text file, where each line represents a locally trending 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 " #[PERIOD]-UTIL-SLOPE " appears and is followed by the LTHUI periods of the itemset. Then, they are followed by the itemset’s utility and statistical slope in those LTHUI periods. For example, we show below the output file for this example.

2 #PERIOD-UTIL-SLOPE[1,9] (82,14.0)
2 3 #PERIOD-UTIL-SLOPE[1,9] (95,14.0)

For example, the last line indicates that the itemset {2, 3} is a LTHUI and its LTHUI period is [1, 9], the utility and statistical slope of the {2, 3} in [1, 9] is 95 and 14.0 respectively. The other lines follow the same format. Note that an itemset may have more than one LTHUI period.


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, locally trending high-utility itemset mining algorithms are generally slower than high uility itemset mining algorithms when the average utility of the two algorithms are equal.

Implementation details

The version implemented here contains all the optimizations described in the paper proposing LTHUI-Miner. Note that the calculation method of statistical slope here is slightly different from that in the paper (Mining Locally Trending High Utility Itemsets), but both methods are able to find trends.

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

This is the reference of the article describing the LTHUI-Miner algorithm:

Fournier-Viger, P., Yang, Y., Lin, J. C.W., Frnda, J. (2020). Mining Locally Trending High Utility Itemsets. Proc. 24th Pacific-Asia Conf. Knowledge Discovery and Data Mining (PAKDD 2020), Springer, LNAI, pp.99-111. [video] [ppt]

The datasets used in the paper can be found here.

Besides, for a general overview of high utility itemset mining, you may read this survey paper.