Skip to content

Run the command line tool

This guide shows how to mine frequent itemsets from a transaction database file using the fpgrowth command. It assumes the package is installed (see Getting started); if it is not, prefix the commands with PYTHONPATH=src and use python3 -m fpgrowth instead of fpgrowth.

Mine a database

fpgrowth -i <in_file> [-o <out_file>] [-m <min_supp>]
Option Meaning Default
-i, --in_file Input transaction database. Required. —
-o, --out_file Output results file. MiningResults.txt
-m, --min_supp Relative minimum support in [0, 1]. 0.5

Example:

fpgrowth -i data.txt -m 0.25 -o results.txt

Interpret the minimum support

-m is relative: it is multiplied by the number of transactions to obtain the absolute count an itemset must reach. With four transactions, -m 0.5 requires support >= 2.

To require an absolute count, divide it by the transaction count. For example, to require support >= 3 in a 4-transaction database, use -m 0.75.

Read the output

The output file begins with |FPs| = <count> and then lists each frequent itemset as <items> : <support>. Lines are sorted by itemset size and content, so the file is deterministic. See the file formats reference.

The command also prints the total number of frequent itemsets to standard output.

Exit behaviour

  • On success the process returns 0.
  • If -m is outside [0, 1], the tool raises ValueError (a non-zero exit).
  • If the input file is missing or malformed, Python raises OSError or ValueError describing the problem.

Check the version

fpgrowth --version