affinity: Computing Affinity Between Items

affinityR Documentation

Computing Affinity Between Items

Description

Provides the generic function affinity() and methods to compute and return a similarity matrix with the affinities between items for a set itemsets stored in a matrix or in transactions via its superclass itemMatrix.

Usage

affinity(x)

## S4 method for signature 'matrix'
affinity(x)

## S4 method for signature 'itemMatrix'
affinity(x)

Arguments

x

a matrix or an object of class itemMatrix or transactions containing itemsets.

Details

Affinity between the two items i and j is defined by Aggarwal et al. (2002) as

A(i,j) = \frac{supp(\{i,j\})}{supp(\{i\}) + supp(\{j\}) - supp(\{i,j\})},

where supp(.) is the support measure. Note that affinity is equivalent to the Jaccard similarity between items.

Value

returns an object of class ar_similarity which represents the affinities between items in x.

Author(s)

Michael Hahsler

References

Charu C. Aggarwal, Cecilia Procopiuc, and Philip S. Yu (2002) Finding localized associations in market basket data, IEEE Trans. on Knowledge and Data Engineering, 14(1):51–62.

See Also

Other proximity classes and functions: dissimilarity(), predict(), proximity-classes

Examples

data("Adult")

## choose a sample, calculate affinities
s <- sample(Adult, 500)
s

a <- affinity(s)
image(a)

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