我在 Python 中收到错误 "MemoryError"。当我找到关联规则并保留在 list() 中时

I get an error "MemoryError" in Python. When I find association rules and keep in list()

此代码:

assoc_rules = apriori(records_mongo, min_support=0.5)
assoc_result = list(assoc_rules)

当我 运行 这段代码时,结果显示 -

Traceback (most recent call last):
File "E:/mongodb_python/app2.py", line 54, in assoc_result = list(assoc_rules)
File "E:\mongodb_python\venv\lib\site-packages\apyori.py", line 288, in apriori
for support_record in support_records:
File "E:\mongodb_python\venv\lib\site-packages\apyori.py", line 203, in gen_support_records
candidates = _create_next_candidates(relations, length)
File "E:\mongodb_python\venv\lib\site-packages\apyori.py", line 157, in create_next_candidates
return list(tmp_next_candidates)
MemoryError

Apriori 可能会非常 内存密集型,当您使用较低的最小支持时。

此外,不要使用 apyori。最后我检查了它只是糟糕的代码,不完整并且没有实现 Apriori 算法。那里有很多糟糕的图书馆!请改用 pyfim。