itemsets-class {arules}R Documentation

Class itemsets — A Set of Itemsets


The itemsets class represents a set of itemsets and the associated quality measures.


Itemsets are usually created by calling an association rule mining algorithm like apriori. Itemsets store the items as an object of class itemMatrix.

To create itemsets manually, the itemMatrix for the items of the itemsets can be created using itemCoding. An example is in the Example section below.

Mined itemsets sets typically contain several interest measures accessible with the quality method. Additional measures can be calculated via interestMeasure.

Objects from the Class

Objects are the result of calling the functions apriori (e.g., with target="frequent itemsets" in the parameter list) or eclat. Objects can also be created by calls of the form

new("itemsets", ...)

or by using the constructor function

itemsets(items, itemLabels, quality = data.frame()).

items need to be a list describing the items (using labels or item ids) and itemLabels needs to be a vector of all possible item labels (character) or a transactions object to copy the item coding (see itemCoding for details).



object of class itemMatrix containing the items in the set of itemsets


a data.frame containing the quality measures for the itemsets


object of class tidLists containing the IDs of the transactions which support each itemset. The slot contains NULL if no transactions ID list is available (transactions ID lists are only available for eclat).


Class associations, directly.



signature(from = "itemsets", to = "data.frame"); represent the itemsets in readable form


signature(x = "itemsets"); returns the itemMatrix representing the set of itemsets


signature(x = "itemsets"); replaces the itemMatrix representing the set of itemsets


signature(object = "itemsets"); returns the whole item information data frame including item labels


signature(object = "itemsets"); returns labels for the itemsets as a character vector. The labels have the following format: "item1, item2,..., itemn"


signature(object = "itemsets"); returns the item labels used to encode the itemsets as a character vector. The index for each label is the column index of the item in the binary matrix.


signature(x = "itemsets"); number of all possible items in the binary matrix representation of the object.


signature(object = "itemsets")


signature(object = "itemsets"); returns the transaction ID list


Michael Hahsler

See Also

associations-class, [-methods, apriori, c, duplicated, eclat, inspect, is.maximal, itemCoding length, match, sets, size, subset, tidLists-class



## 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]

## 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"),
  ), itemLabels = Adult)

quality(twoitemsets) <- data.frame(support = interestMeasure(twoitemsets, 
  measure = c("support"), transactions = Adult))


[Package arules version 1.7-1 Index]