# Mining High-Utility Itemsets based on Particle Swarm Optimization with the HUIM-BPSO-tree algorithm (SPMF documentation)

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

## How to run this example?

• If you are using the graphical interface, (1) choose the "HUIM-BPSO-tree" algorithm, (2) select the input file "contextHUIM.txt", (3) set the output file name (e.g. "output.txt"), (4) set the minutil threshold to 40, and (4) click "Run algorithm".
• If you want to execute this example from the command line, then execute this command:
java -jar spmf.jar run HUIM-BPSO-tree contextHUIM.txt output.txt 40
in a folder containing spmf.jar and the example input contextHUIM.txt.
• If you are using the source code version of SPMF, launch the file "MainTestHUIM_BPSO_tree.java" in the package ca.pfv.SPMF.tests.

## What is HUIM-BPSO-tree?

HUIM-BPSO-tree is an algorithm for discovering high utility itemsets (HUIs) which have utility value no less than the minimum utility threshold in a transaction database. The HUIM-BPSO-tree algorithm discovers HUIs based on binary particle swarm optimization (BPSO) algorithm and designed OR/NOR-tree structure to avoid combinations, which can improve the efficiency to discovering HUIs.

## What is the input?

HUIM-BPSO-tree takes as input a transaction database with utility information. Let's consider the following database consisting of 7 transactions (t1,t2, ..., t7) and 5 items (1, 2, 3, 4, 5). This database is provided in the text file "contextHUIM.txt" in the package ca.pfv.spmf.tests of the SPMF distribution.

 Items Transaction utility Item utilities for this transaction t1 2 3 4 9 2 2 5 t2 1 2 3 4 5 18 4 2 3 5 4 t3 1 3 4 11 4 2 5 t4 3 4 5 11 2 5 4 t5 1 2 4 5 22 5 4 5 8 t6 1 2 3 4 17 3 8 1 5 t7 4 5 9 5 4

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).

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

## What is the output?

The output of HUIM-BPSO-tree is the set of high utility itemsets. An itemset X in a database D is a high-utility itemset (HUI) iff its utility is no less than the minimum utility threshold. For example, if we run HUIM-BPSO-tree and set minimum utility threshold as 40, we obtain 2 high utility itemsets.

 itemsets utility {4,5} 40 {1,2,4} 41

## Input file format

The input file format of high utility itemsets is defined as follows. It is a text file. Each lines represents a transaction. Each line is composed of three 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.

For example, for the previous example, the input file is defined as follows:
2 3 4:9:2 2 5
1 2 3 4 5:18:4 2 3 5 4
1 3 4:11:4 2 5
3 4 5:11:2 5 4
1 2 4 5:22:5 4 5 8
1 2 3 4:17:3 8 1 5
4 5:9:5 4

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

## Output file format

The output file format of high utility itemsets is defined as follows. It is a text file, each following 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 " #UTILITY: " appears and is followed by the utility of the itemset. For example, we show below the output file for this example.
4 5 #UTIL: 40
1 2 4 #UTIL: 41

For example, the first line indicates that the itemset {4, 5} is a high utility itemset which has utility equals to 41. The following lines follows the same format.

## Implementation details

The version implemented here contains all the optimizations described in the paper proposing HUIM-BPSO-tree. Note that the input format is not exactly the same as described in the original article. But it is equivalent.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8559107,"math_prob":0.7605134,"size":5596,"snap":"2022-40-2023-06","text_gpt3_token_len":1564,"char_repetition_ratio":0.15772532,"word_repetition_ratio":0.051485147,"special_character_ratio":0.27448177,"punctuation_ratio":0.1306914,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9623279,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-02-08T07:37:36Z\",\"WARC-Record-ID\":\"<urn:uuid:2c4f831d-2a67-43b0-806b-e6eb6e494cb7>\",\"Content-Length\":\"10782\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:51b1017d-16b6-447e-a2f8-3509592e0925>\",\"WARC-Concurrent-To\":\"<urn:uuid:e3e6f46e-c962-4043-a7fc-69ce4d32d507>\",\"WARC-IP-Address\":\"172.67.193.154\",\"WARC-Target-URI\":\"http://www.philippe-fournier-viger.com/spmf/HUIM-BPSO-tree.php\",\"WARC-Payload-Digest\":\"sha1:FPWYAZMPRLKJEJLM5MR3MKXQXRATXET7\",\"WARC-Block-Digest\":\"sha1:UIUZ3BQ6CSNQGX7V3HOKDRRYXDIGDWF7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764500719.31_warc_CC-MAIN-20230208060523-20230208090523-00332.warc.gz\"}"}