data("Adult")
## Mine frequent itemsets with Eclat.
fsets <- eclat(Adult, parameter = list(supp = 0.5))
## Display the 5 itemsets with the highest support.
fsets.top5 <- sort(fsets)[1:5]
inspect(fsets.top5)
## Get the itemsets as a list
as(items(fsets.top5), "list")
## Get the itemsets as a binary matrix
as(items(fsets.top5), "matrix")
## Get the itemsets as a sparse matrix, a ngCMatrix from package Matrix.
## Warning: for efficiency reasons, the ngCMatrix you get is transposed
as(items(fsets.top5), "ngCMatrix")
## Manually create itemsets with the item coding in the Adult dataset
## and calculate some interest measures
twoitemsets <- itemsets(
items = list(
c("age=Young", "relationship=Unmarried"),
c("age=Old")
), itemLabels = Adult)
quality(twoitemsets) <- data.frame(support = interestMeasure(twoitemsets,
measure = c("support"), transactions = Adult))
inspect(twoitemsets)
Run the code above in your browser using DataLab