我正在尝试创建一个函数,该函数使用来自 mlxtend 的 Apriori 算法挖掘和导出项目类别之间的关联规则。虽然这在 jupyter 笔记本中效果很好。当我将相同的函数复制到我的 pycharm 项目中时,出现类型错误。
在这两种情况下,我都使用了 mlxtend 0.15.0.0。
def apriori():
inputPath = inputPathField.get()
data = pd.read_csv(inputPath, usecols=['BillId', 'Level5'])
data['dummy'] = 1
matrix = data.pivot_table(values='dummy', index='BillId', columns='Level5').fillna(0)
frequent_itemsets = apriori(matrix, min_support=0.0005, use_colnames=True)
rules = association_rules(frequent_itemsets, metric="lift", min_threshold=1)
export = rules[(rules.antecedents.str.len() <= 3)]
export = export[(export.consequents.str.len() == 1)]
export = export[(export.confidence >= 0.15)]
outputPath = outputPathField.get()
export.to_csv(outputPath)
File "/home/scrybe/PycharmProjects/tkinter/Apriori.py", line 37, in apriori
frequent_itemsets = apriori(matrix, min_support=0.0005, use_colnames=True)
TypeError: apriori() got an unexpected keyword argument 'min_support'