函数在JuPyter Notebook中不在PyCharm中引发TypeError

时间:2019-06-26 15:58:44

标签: pycharm jupyter-notebook apriori mlxtend

我正在尝试创建一个函数,该函数使用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'

1 个答案:

答案 0 :(得分:0)

问题是我使用的函数名已经是mlxtend中的函数名。更改后,问题已解决。感谢@vishal。