13
$\begingroup$

Could anyone please recommend a good frequent itemset package in python? I only need to find frequent itemset, no need of finding the association rules.

$\endgroup$
1
  • $\begingroup$ In my personal exp, I found R's apriori and FP-growth much better than their Python alternatives. So, if you're open to considering R, you should try them :) $\endgroup$
    – Dawny33
    Commented Mar 9, 2017 at 6:09

3 Answers 3

11
$\begingroup$

I also recommend MLXtend library for frequent itemsets.

usage example:

dataset = [['Milk', 'Onion', 'Nutmeg', 'Kidney Beans', 'Eggs', 'Yogurt'],
           ['Dill', 'Onion', 'Nutmeg', 'Kidney Beans', 'Eggs', 'Yogurt'],
           ['Milk', 'Apple', 'Kidney Beans', 'Eggs'],
           ['Milk', 'Unicorn', 'Corn', 'Kidney Beans', 'Yogurt'],
           ['Corn', 'Onion', 'Onion', 'Kidney Beans', 'Ice cream', 'Eggs']]

te = TransactionEncoder()

te_ary = te.fit(dataset).transform(dataset)

df = pd.DataFrame(te_ary, columns=te.columns_)

frequent_itemsets = apriori(df, min_support=0.1, use_colnames=True)

print frequent_itemsets
$\endgroup$
1
  • $\begingroup$ this package has memory error when you have too many distinct items. Not recommended for Big Data $\endgroup$
    – Snow
    Commented Jul 7, 2020 at 12:40
4
$\begingroup$

Orange3-Associate package provides frequent_itemsets() function based on FP-growth algorithm.

$\endgroup$
3
$\begingroup$

MLXtend library has been really useful for me. In its docummentation there is an Apriori implementation that outputs the frequent itemset.

Please check the first example available in http://rasbt.github.io/mlxtend/user_guide/frequent_patterns/apriori/.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.