0
votes

I am mining some rules using the arules and arulesviz packages in R. I was able to specify the LHS and RHS for the rule mining. However, I want to specify multiple parameters in the LHS and RHS and then check the support and confidence on these rules.

I have tried mining the rules specifying the LHS but the results I am getting include both, rules for each parameter as well as rules for both parameters combined.

rules_sales <- apriori(sales, 
                        parameter=list(support =0.001, confidence =0.001, minlen=2, maxlen=4), 
                        appearance = list(lhs=c("warehouse=Antwerp", "cargo=Drones"), 
                                          rhs=paste0("importCountries=", unique(sales$importCountries)), default="none"))
 inspect(rules_sales)

Expected Result should only include

{warehouse=Antwerp,cargo=Drones} => {importCountries=***} 0.030937427 0.54508197  4.1074625 266 

and not 

{warehouse=Antwerp} => {importCountries=***}  0.030937427 0.54508197  4.1074625 266 
1

1 Answers

0
votes

From the documentation (? APappearance):

lhs, rhs, both, items, none: character vectors giving the labels of the items which can appear in the specified place (rhs, lhs or both for rules and items for itemsets)

This means that either of the items specified in LHS can appear there. If you specify two items and only want rules with both in the LHS then set minlen = 3 (2 for LHS + 1 for RHS).