Why does apriori algorithm do not return frequency of candidates?

44 Views Asked by At

I am trying to run apriori algorithm in R. But it is not working. First of all, I have the following code.

#creating data frame

library(arules)
library(dplyr)
order_id <- c('AG-2011-2040','IN-2011-47883', 'HU-2011-1220','IT-2011-3647632','IN-2011-47883','IN-2011-47883','IN-2011-30733','CA-2011-115161','AO-2011-1390','ID-2011-56493'  )
product_name <- c('Tenex Lockers, Blue','Acme Trimmer, High Speed', 'Tenex Box, Single Width', 'Enermax Note Cards, Premium','Eldon Light Bulb, Duo Pack','Eaton Computer Printout Paper, 8.5 x 11', 'Brother Personal Copier, Laser','Sauder Facets Collection Library, Sky Alder Finish', 'Fellowes Lockers, Wire Frame','Tenex Trays, Single Width')
df <- data.frame(order_id, product_name)

#renaming columns
colnames(df) <- c('order.id', 'product.name')

#removing adjective after comma for each product
df$product.name <- gsub(",.*", "", df$product.name)

#aggegating product name by id
agg_prod_df <- data.frame(aggregate(product.name~order.id, df, paste, collapse=", "))

#converting each column in the db as factor 
agg_prod_df$product.name <- as.factor(agg_prod_df$product.name)
agg_prod_df$order.id <- as.factor(agg_prod_df$order.id)

#converting the df to transactions
transaction_data <- as(agg_prod_df, "transactions")

#running apriori algorith 
apriori(transaction_data, parameter = list(supp = 0.001, conf =0.02))

When I run the code, I expect it to produce a list of products with frequency of different products in each transactions. However, I get an empty list back. I have tried to play with the confidence and support level. But no matter what I change, it doesn't give me any result back. I only get the followin output.

Parameter specification:
 confidence minval smax arem  aval originalSupport maxtime support minlen maxlen target  ext
       0.02    0.1    1 none FALSE            TRUE       5   0.001      1     10  rules TRUE

Algorithmic control:
 filter tree heap memopt load sort verbose
    0.1 TRUE TRUE  FALSE TRUE    2    TRUE

Absolute minimum support count: 25 

set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[39494 item(s), 25035 transaction(s)] done [0.15s].
sorting and recoding items ... [113 item(s)] done [0.00s].
creating transaction tree ... done [0.00s].
checking subsets of size 1 done [0.00s].
writing ... [0 rule(s)] done [0.00s].
creating S4 object  ... done [0.00s].
set of 0 rules 

Thanks in advance for your help! Since it is not an error mesage, I can't quite figure out where I did wrong.

0

There are 0 best solutions below