gpt4 book ai didi

python - 使用 Python mlxtend 的关联规则

转载 作者:行者123 更新时间:2023-11-28 19:02:43 25 4
gpt4 key购买 nike

我有一个数据列表,我想在其中找到关联。我使用 -

找到了频繁项集
frequent_itemsets = apriori(df, min_support=0.01, use_colnames=True)

给出频繁项集为 -

        support  itemsets
0 0.020438 [AUCKLAND]
1 0.015320 [Adelaide]
2 0.043066 [Auckland]
....

我需要找到信心。我将关联规则函数用作 -

aa = association_rules(frequent_itemsets, metric="confidence", min_threshold=0.001)

但是有了这个,我得到了一个只有列名的空白表。

最佳答案

records = []<br/>
for i in range(0, 7501):<br/>
records.append([str(store_data.values[i,j]) for j in range(0, 20)])
association_rules = apriori(records, min_support=0.0045, min_confidence=0.2, min_lift=3, min_length=2)

i think you code should be something like this you shouldn't pass the frequent_itemsets in case of association rule to apply as it works for you data separately rather you should use the appended name as i have used records in my case. i hope you might get some idea.

关于python - 使用 Python mlxtend 的关联规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50794833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com