【发布时间】:2021-11-29 22:49:50
【问题描述】:
我想使用关联规则分析来自我的电子商店的客户数据。这些是我采取的步骤:
首先:我的数据框 raw_data 有三列 ["id_customer","id_product","product_quantity"],它包含 700,000 行。
第二:我重新排序我的数据框,我得到一个包含 680,000 行和 366 列的数据框:
customer = (
raw_data.groupby(["id_customer", "product_id"])["product_quantity"]
.sum()
.unstack()
.reset_index()
.fillna(0)
.set_index("id_customer")
)
customer[customer != 0] = 1
最后:我想创建一个项目的频率:
from mlxtend.frequent_patterns import apriori
frequent_itemsets = apriori(customer, min_support=0.00001, use_colnames=True)
但现在我收到一个错误MemoryError: Unable to allocate 686. GiB for an array with shape (66795, 2, 689587) and data type float64
如何解决?或者如何在不使用apriori函数的情况下计算frequent_itemsets?
【问题讨论】: