Comparison with existing libraries¶
This page summarises the head-to-head evaluation in benchmarks/COMPARISON.md. The full report
is generated by benchmarks/library_comparison.py and can be reproduced with the commands at the
end of this page.
Tested on 2026-11-12 with Python 3.12.4, mlxtend 0.25.0, numpy 2.3.5, pandas 3.1.1 and scipy 1.18.1.
Correctness¶
Frequent itemsets and absolute counts are identical to mlxtend's fpgrowth on Groceries at
minimum support 0.02, 0.01, 0.005 and 0.002:
| minimum support | mlxtend itemsets | rulewise itemsets | identical |
|---|---|---|---|
| 0.02 | 122 | 122 | yes |
| 0.01 | 333 | 333 | yes |
| 0.005 | 1,001 | 1,001 | yes |
| 0.002 | 4,223 | 4,223 | yes |
The statistical layer is an addition, not a different miner.
Pure noise¶
500 independent null datasets, 3,000 transactions, 25 items, varied item frequencies. Nominal level 0.05.
| method | mean rules | datasets with at least one rule | rate (95% CI) |
|---|---|---|---|
| mlxtend | 1,929 | 500/500 | 1.000 |
| rulewise holdout | 0.02 | 4/500 | 0.008 (0.003-0.020) |
| rulewise direct | 0.01 | 4/500 | 0.008 (0.003-0.020) |
The four false-positive datasets each returned one association as two symmetric rules. That is a legitimate 5% level false discovery, not a bug. mlxtend's rules were also tested on a fresh null sample: 4.2% replicated, about what chance predicts.
Groceries¶
Five random halves. Rules were found on one half and evaluated on the other. "Productive" means the rule still beats every simpler version of itself on the held-out half.
| method | rules | productive on held-out | lift > 1 | productive rules vs classical | fit |
|---|---|---|---|---|---|
| classical all | 670 | 48.8% | 98.5% | 100% | 0.19 s |
| classical lift >= 2 | 350 | 48.9% | 99.9% | 52.1% | - |
| classical top-K by lift | 174 | 47.0% | 100% | 25.1% | - |
| mlxtend plus Fisher and Holm | 185 | 64.9% | 100% | 37.0% | - |
| rulewise holdout | 116 | 98.7% | 100% | 35.3% | 0.05 s |
| rulewise direct | 174 | 99.3% | 100% | 53.6% | 0.07 s |
Classical rules on this data are mostly real: 98.5% still have lift above 1 on held-out baskets. Their problem is redundancy, not statistical falsehood. About half are no longer productive once simpler rules are considered. rulewise keeps 98% to 99% of what it returns productive, at the cost of recall.
The mlxtend plus Fisher and Holm row is the strongest classical statistical baseline: select
candidates on one half, test the 2x2 association on the other half, correct with Holm. Only 3.1%
of those rules survived the productivity test on a third evaluation in the planted benchmark. A
significant association is not the same as a non-redundant rule.
Planted rules¶
Five datasets, 20,000 baskets, 30 items, four planted rules and 15% noise. Rules were mined on one half and evaluated on the other.
| method | rules | productive on test | planted recall | exact planted precision | reliable F1 |
|---|---|---|---|---|---|
| classical all | 15,685 | 1.4% | 100% | 0.0% | 0.03 |
| classical top-35 by lift | 35 | 9.1% | 65% | 7.4% | 0.16 |
| classical top-35 by confidence | 35 | 1.1% | 0% | 0.0% | 0.00 |
| mlxtend plus Fisher and Holm | 3,486 | 3.1% | 100% | 0.1% | 0.06 |
| rulewise holdout | 35 | 100.0% | 100% | 11.4% | 1.00 |
| rulewise direct | 35 | 100.0% | 100% | 11.4% | 1.00 |
The exact planted precision is low because rulewise also returns genuine sub-rules and reverse rules, not because it returns false rules. The reliable F1 combines productive precision with planted recall; read it as a summary of a trustworthy set, not as a count of planted rules.
Fit time¶
Single core, this machine. rulewise was faster than mlxtend in these runs even though it tests every candidate, because it never materialises the full rule list.
| data | mlxtend | efficient-apriori | rulewise holdout | rulewise direct |
|---|---|---|---|---|
| Groceries, 169 items, support 0.005 | 0.35 s | 0.17 s | 0.08 s | 0.09 s |
| synthetic, 20k x 30, support 0.01 | 2.62 s | 8.25 s | 0.62 s | 0.75 s |
| dense null, 50k x 60, support 0.0005 | 8.39 s | 119.33 s | 2.75 s | 4.26 s |
Speed is not the contribution. The statistical pass grows with the number of candidates, so dense data at low support can be slow. The optional PyFIM backend was not testable on Python 3.12 and Windows; the core uses the pure-Python backend.
Classifier¶
UCI Mushrooms, 5-fold cross-validation with 3 repeats. Accuracy and log-loss.
| model | accuracy | log-loss | rules |
|---|---|---|---|
| majority class | 0.518 | 0.693 | - |
| logistic regression | 0.9998 | 0.0007 | - |
| decision tree, depth 6 | 0.9959 | 0.0141 | - |
| rulewise holdout | 0.9957 | 0.0209 | 1,042 |
| rulewise direct | 0.9970 | 0.0113 | 1,373 |
Mushrooms is a best case for an associative classifier: categorical features and strong conjunctions. rulewise is competitive but does not beat logistic regression. On dense numeric data the gap is much larger; see Limitations.
Recommendation¶
One hidden item per held-out Groceries basket, hit@5:
| method | hit@5 | coverage |
|---|---|---|
| popularity | 26.4% | 100% |
| classical all | 20.1% | 92.7% |
| rulewise holdout | 18.7% | 85.3% |
| rulewise direct | 19.7% | 90.2% |
A popularity baseline wins on raw hit rate. Use recommend when you need an explanation, not
when you need the best hit rate.
What the comparison supports¶
Supported:
- exact frequent-itemset mining;
- empirical error control on null data;
- much higher held-out productivity than a classical list;
- honest effect sizes in holdout mode;
- a compact, readable rule set;
- speed at these scales;
- a scikit-learn-compatible API.
Not supported:
- higher recall than a classical list;
- better recommendation hit rate than popularity;
- better classification than logistic regression or a tree;
- a full replacement for mlxtend's feature set (closed itemsets, many metrics, constraints).
Positioning¶
Use mlxtend when you want the full classical catalogue, many metrics, or closed and maximal itemsets. Use rulewise when a short, statistically vetted list matters more than recall, and when you need to defend each rule to a reviewer, an auditor or a domain expert.
Reproduce¶
pip install -e ".[dev]"
python benchmarks/get_data.py
python benchmarks/library_comparison.py --section all --runs 500 --seeds 5 \
--out benchmarks/COMPARISON.md
The internal review with the full discussion is in benchmarks/PRE_PUBLISH_REVIEW.md.