-
Notifications
You must be signed in to change notification settings - Fork 887
Description
Hi,
I tried using the assosciative_rules() function for a project of mine and noticed that I was getting the following error:
TypeError: association_rules() missing 1 required positional argument: 'num_itemsets'
I suspect that this is an oversight in the source code as the previous release didn't have this bug. I hope that this would be addressed and patched.
Code to reproduce the bug
The example code from the User Guide of the association_rules() function can be used to reproduce this bug.
https://rasbt.github.io/mlxtend/user_guide/frequent_patterns/association_rules/
import pandas as pd
from mlxtend.preprocessing import TransactionEncoder
from mlxtend.frequent_patterns import apriori, fpmax, fpgrowth
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 = fpgrowth(df, min_support=0.6, use_colnames=True)
### alternatively:
#frequent_itemsets = apriori(df, min_support=0.6, use_colnames=True)
#frequent_itemsets = fpmax(df, min_support=0.6, use_colnames=True)
from mlxtend.frequent_patterns import association_rules
association_rules(frequent_itemsets, metric="confidence", min_threshold=0.7)Expected Results

Results from the User Guide of the association_rules() function.
Actual Results
Traceback (most recent call last):
File "c:\Users\siddh\OneDrive\Desktop\bug-report.py", line 25, in
association_rules(frequent_itemsets, metric="confidence", min_threshold=0.7)
TypeError: association_rules() missing 1 required positional argument: 'num_itemsets'
Versions
MLxtend 0.23.2
Windows-10-10.0.22631-SP0
Python 3.11.8 | packaged by Anaconda, Inc. | (main, Feb 26 2024, 21:34:05) [MSC v.1916 64 bit (AMD64)]
Scikit-learn 1.5.2
NumPy 1.26.4
SciPy 1.11.4