python - 使用 Python mlxtend 的关联规则
问题描述
我有一个数据列表,我想在其中找到关联。我发现频繁项集使用 -
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 = []
for i in range(0, 7501):
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)
我认为你的代码应该是这样的,你不应该在关联规则的情况下传递frequent_itemsets,因为它单独适用于你的数据,而不是你应该使用附加的名称,因为我在我的案例中使用了记录。我希望你能有所了解。
推荐阅读
- amazon-dynamodb - 重试因 ProvisionedThroughputExceededException 而失败的请求时,标准 AmazonDynamoDBClient 是否使用指数回退?
- kubernetes - com.hazelcast.client.AuthenticationException:凭据无效!校长:空
- java - Kafka 流 DSL:窗口聚合的应用程序滞后
- vba - 为什么这个循环返回重复的结果?
- google-sheets - 查询并转置一长行数据 Google Sheets
- javascript - RequireJS / XMLHttpRequest 问题 - TypeError: 找不到在对象函数 localRequire(deps, callback, errback) {...} 中打开的函数
- javascript - Javascript onmousemove 和 onclick
- linux - 如何从不同的目录写入文件,将名称和编号放入该文件并对其进行排序并打印更新的文件
- azure-sql-database - 将 Azure 表数据与 Cosmos Db 进行比较
- docker - 增加 docker-compose 容器的堆大小