Search code examples
raprioriarules

Apriori in R: LHS does not mention all items


How does the apriori algorithm work when it lists a rule like :

{U-41} => {U-39} 0.25    1          4.000000
{U-39} => {U-41} 0.25    1          4.000000
{U-41} => {U-40} 0.25    1          1.333333
{U-39} => {U-40} 0.25    1          1.333333

Why it not available in the LHS the {U-40} ? How can I in fact filter the rule by {U-40} in the LHS if it is not mentioned there ?

His is my data

ID  PRODUCT
200001047;U-39
200001047;U-40
200001047;U-41
200003868;U-40
200007480;U-40
200007481;U-0 

And this is the R code I have used

library(arules)
csv <- read.csv("C:/prova.csv",header=FALSE, sep=";")
dt <- as(csv,"data.frame")
colnames(dt) <- c("ID", "PRODUCT")    
sl <- split(dt$PRODUCT,dt$ID)
tran <- as(sl,"transactions") 
rules <- apriori(tran, parameter = list(minlen=2, target="rules"))
inspect(rules)

Thanks, Duilio


Solution

  • I am not sure that I understand your question. Would you expect to see U-40 in the lhs? With your dataset the confidence of these rules is very low. You will have to reduce minimum confidence.