itemsets-class: Class itemsets - A Set of Itemsets

itemsets-classR Documentation

Class itemsets — A Set of Itemsets

Description

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

Usage

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

## S4 method for signature 'itemsets'
summary(object, ...)

## S4 method for signature 'itemsets'
length(x)

## S4 method for signature 'itemsets'
nitems(x)

## S4 method for signature 'itemsets'
labels(object, ...)

## S4 method for signature 'itemsets'
itemLabels(object)

## S4 replacement method for signature 'itemsets'
itemLabels(object) <- value

## S4 method for signature 'itemsets'
itemInfo(object)

## S4 method for signature 'itemsets'
items(x)

## S4 replacement method for signature 'itemsets'
items(x) <- value

## S4 method for signature 'itemsets'
tidLists(x)

Arguments

items

an itemMatrix or an object that can be converted using encode().

itemLabels

item labels used for encode().

quality

a data.frame with quality information (one row per itemset).

object, x

the object

...

further argments

value

replacement value

Details

Itemsets are usually created by calling an association rule mining algorithm like apriori(). 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 contain several interest measures accessible with the quality() method. Additional measures can be calculated via interestMeasure().

Functions

  • summary(itemsets): create a summary

  • length(itemsets): get the number of itemsets.

  • nitems(itemsets): get the number of items (columns) in the current encoding.

  • labels(itemsets): get the itemset labels.

  • itemLabels(itemsets): get the item labels.

  • itemLabels(itemsets) <- value: replace the item labels.

  • itemInfo(itemsets): get item info data.frame.

  • items(itemsets): get items as an itemMatrix.

  • items(itemsets) <- value: with a different itemMatrix.

  • tidLists(itemsets): get tidLists stored in the object (if any).

Slots

items

an itemMatrix object representing the itemsets.

tidLists

a tidLists or NULL.

quality

a data.frame with quality information

info

a list with mining information.

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().

Coercions

  • as("itemsets", "data.frame")

Author(s)

Michael Hahsler

See Also

Superclass: associations

Other associations functions: abbreviate(), associations-class, c(), duplicated(), extract, inspect(), is.closed(), is.generator(), is.maximal(), is.redundant(), is.significant(), is.superset(), match(), rules-class, sample(), sets, size(), sort(), unique()

Examples

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)

arules documentation built on April 1, 2023, 12:05 a.m.