我在R中编写了以下代码,以在其上运行Apriori算法:
df_itemList<- read.csv('data.3.txt')
write.csv(df_itemList,"ItemList.csv", row.names = TRUE)
txn = read.transactions(file="ItemList.csv", rm.duplicates= TRUE, format="basket",sep=",",cols=1);
basket_rules <- apriori(txn,parameter = list(sup = 0.01, conf = 0.5,target="rules"));
df_basket <- as(basket_rules,"data.frame")
write.csv(df_basket,"ItemList2.csv", row.names = TRUE)
代码工作得很好,并且给了我预期的规则,但是当我在真实的数据集“ 2000行”上运行它时,它会在几秒钟内执行,并且仅给出4个琐碎的规则