【发布时间】:2021-12-18 14:38:55
【问题描述】:
我有来自 eshop 的 1200 万条数据。我想使用efficient_apriori 包计算关联规则。 The problem is that 12 millions observations are too many,所以计算时间太长了。有没有办法加快算法的速度?我正在考虑一些并行处理或将 python 代码编译成 C。我尝试了 PYPY,但 PYPY 不支持 pandas 包。感谢您提供任何帮助或想法。
如果你想看我的代码:
import pandas as pd
from efficient_apriori import apriori
orders = pd.read_csv("orders.csv", sep=";")
customer = orders.groupby("id_customer")["name"].agg(tuple).tolist()
itemsets, rules = apriori(
customer, min_support=100/len(customer), min_confidence=0
)
【问题讨论】:
-
您的 12M 数据需要多长时间?
-
@ferdy 我在 10 小时后停止了它..
-
我在github.com/remykarem/apriori-rs/tree/master/benchmarks/data 获取了数据,大约 500k+,然后将其复制 20 倍到另一个文件中以达到 10M+。
csv to dataframe: 60s, groupby: 3s, apriori: 14s一共77s我用customer = orders.groupby("Invoice")["StockCode"].agg(tuple).tolist()