Skip to content

File formats

Transaction database (input)

A plain-text file with two parts.

  1. The first line is a single integer: the number of transactions.
  2. Every subsequent non-blank line is one transaction with three tab-separated fields:
Field Meaning
1 Transaction id (integer).
2 Number of items in the transaction (integer).
3 Items separated by single spaces.

Example:

4
1   3   1 3 4
2   3   2 3 5
3   4   1 2 3 5
4   2   2 5

The field separator is a tab, not a comma or space. By default items are parsed as integers; pass item_parser=str (or another callable) to read_database for other item types.

The item count field is read but not enforced against the actual number of items. The declared transaction count is likewise not enforced.

Parsing rules

  • Blank lines are ignored.
  • A line without exactly three tab-separated fields raises ValueError.
  • The transaction id and item count must parse as integers.

Results file (output)

The first line is:

|FPs| = <count>

Each following line is one frequent itemset:

<items> : <support>

where <items> are the items separated by single spaces and <support> is the absolute support count. Lines are sorted by itemset size and then by their rendered text, which makes the file deterministic.

Example:

|FPs| = 9
1 : 2
2 : 3
3 : 3
5 : 3
1 3 : 2
2 3 : 2
2 5 : 3
3 5 : 2
2 3 5 : 2