如何从apriori算法的输出中提取UPC?

时间:2015-06-27 23:32:21

标签: r market-basket-analysis

我有apriori算法的输出(包:arules),我想从这个输出中提取UPC?我该怎么做?

生成输出的代码如下:

i<- split(dg1$UPC.Code, dg1$Transaction.ID)

#View the result

head(i)

txn<-as(i,"transactions")

basket_rules <- apriori(txn, parameter = list(sup = 0.0005, conf = 0.0001, minlen=2,target="rules"))

inspect(basket_rules)

输出如下:

lhs               rhs                 support confidence       lift
1   {51500764213}  => {51500605660}  0.0005765499 0.47621383 333.340972
2   {51500605660}  => {51500764213}  0.0005765499 0.40357440 333.340972
3   {51500763100}  => {51500601334}  0.0005118291 0.41522158 210.758865
4   {51500601334}  => {51500763100}  0.0005118291 0.25979506 210.758865
5   {644209412006} => {16000459601}  0.0005355798 0.44719881  99.662903
6   {16000459601}  => {644209412006} 0.0005355798 0.11935953  99.662903
7   {15300200029}  => {15300200012}  0.0005587368 0.31056106 151.209386
8   {15300200012}  => {15300200029}  0.0005587368 0.27204394 151.209386
9   {51500555071}  => {51500601334}  0.0005320172 0.36706268 186.314290
10  {51500601334}  => {51500555071}  0.0005320172 0.27004219 186.314290

0 个答案:

没有答案