Repository navigation
v0.1.0
First public version. A pure Go port and further
development of Christian Borgelt's FP-Growth 6.21 (2022-11-22) C
implementation.
Added
- Library package
fpgrowth(github.com/dimchansky/fpgrowth-go): pure
Go, no cgo, no dependencies outside the standard library; Go 1.26 or
later.- Targets: frequent, closed and maximal item sets, generators, and
association rules with a single-item head. - Generic items (any
comparabletype) and replayable sources:
FromItems,FromSlice,Generate,TableFile,TableReader,
CSVFile,CSVReader, andSpoolTable/SpoolCSVfor one-shot
readers. - Three delivery styles for each result kind: iterators (
Itemsets,
Rules), callbacks (MineItemsets,MineRules) and collectors
(CollectItemsets,CollectRules); early stop and cancellation
throughcontext.Context. - Upstream's algorithm variants (
Algorithm) and optimizations
(Tuning), absolute and relative support thresholds (Count,
Fraction), size limits, a per-size support border, transaction
weights, item selection, rule item appearances, 25 rule evaluation
measures with aggregation for item sets,Stats,Summaryand the
pattern spectrum. - Option validation with
ErrInvalidOptionsnaming the field
(including a non-zeroTableFormatwithout record separators, a
nilSourceFunc, and a maximum support below the minimum of the
same kind;SpoolTable/SpoolCSVcheck the format before copying
any input); size limits reported asErrTooLarge. Callback errors
of any type, comparable or not, are returned unchanged. Valueis NaN when no evaluation measure is set; results are
deterministic for the same data, options and version, but their
order is not part of the compatibility promise.
- Targets: frequent, closed and maximal item sets, generators, and
- Command-line program
cmd/fpgrowth, compatible with upstream
fpgrowth6.21: same options, input and output formats, messages and
exit codes, apart from the documented differences below. Standard input
is spooled to a temporary file; SIGINT stops the run with exit status
130. - Development tooling in the nested module
reference/(not part of the
published module): the unmodified upstream sources with a SHA-256
manifest, a scripted C reference build (release, debug, sanitizer and
native variants), and a randomized differential test suite against the
C program with a brute-force checker. - Golden fixtures produced by the C reference (plus Go output snapshots
for the documented differences), property tests against a brute-force
oracle, and fuzz targets for the table reader, the C number
parsers, the transaction bag, the miner, the CSV source and the CLI
option parser. - Benchmarks of the library and the CLI against the C reference
(docs/benchmarks.md). - CI (tests on Linux, macOS and Windows with Go 1.26 and 1.27, race
detector, static analysis, vulnerability scan, fuzz smoke tests,
differential tests) and GoReleaser-based release automation.
Differences from upstream
Every difference is intentional and listed with its kind (upstream
defect fix, platform difference, improvement, new or preserved behavior),
evidence and tests in
docs/differences.md;
they fix 33 distinct, confirmed upstream defects and avoid 2 upstream
crashes. In summary:
- Fixed mining results:
-Atcrashes or wrong item names (M1),-s0and
zero-frequency items (M2), generators missed with-m ≥ 2(M3), maximal
sets missed (M4, M9), non-closed or non-maximal sets with-n(M5).
Negative weights are rejected (M6), supports are 64-bit with an
overflow check (M7), out-of-range thresholds are clamped (M8), a sort
recursion crash on long shared prefixes is avoided (M10), and item
counts saturate instead of overflowing (M11). - Rules and evaluation:
-ebselects the imbalance ratio for rules (R1),
-pprunes as documented (R2), head-only items stay out of rule bodies
(R3),-Sapplies to the same support as-s(R8), and measure edge
cases are corrected (R4-R7, R9, R11; R9c and R11 are latent; R10 fixes the project's
patched C reference only). - Floating point: values are bit-identical to the C reference built
without fused multiply-add, except log-based values, which can differ in
the last bit from the platform's C library (F-1). - CLI output, input and messages:
-hand-gwork as documented, no
spurious empty-set line, count-only mode honors-n, write errors are
reported, escapes, non-ASCII separators, long fields and a last record
without a newline are handled, NaN thresholds are rejected, log times
are wall-clock times, a pre-formatting overflow crash is avoided
(O1-O11, I1-I8, C1-C10). - Numeric limits: the statistical rule measures lose precision at total
transaction weights above about 1e12, and thresholds tolerate rounding
above 2^52 (N1-N3). - Upstream behavior kept on purpose is listed as P1-P6.
Known limitations
- Statistical rule measures at very large total weights (audit
finding ALG-1,docs/differences.mdN1): chi², Yates, the G-test and
information, the Fisher tests, the certainty factor and-iare
computed in float64 as upstream does, and lose precision once the total
transaction weight exceeds about 10^12 (about 1–40 % error from
10^12–10^13, meaningless by 10^14–10^16). Item sets, supports,
confidence and the other measures are not affected. Exact arithmetic
would change the last bits of these values against the C reference on
ordinary data, so it is deferred to a future release.
Not included
- The
fpgpspprogram (fpgpsp.cis in the upstream archive, but the
modules it needs,tars.candpspest.c, are not) and
zlib-compressed output (-z, off in upstream's default build).
Verify a download: sha256sum --ignore-missing -c checksums.txt
(macOS: shasum -a 256 --ignore-missing -c checksums.txt), and its
build provenance: gh attestation verify <file> --repo dimchansky/fpgrowth-go --signer-workflow dimchansky/fpgrowth-go/.github/workflows/release.yml --source-ref refs/tags/v0.1.0 --deny-self-hosted-runners.
The library is installed with go get github.com/dimchansky/fpgrowth-go@v0.1.0.