Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

affinity

Computing Affinity Between Items


Description

Provides the generic function affinity and the S4 methods to compute and return a similarity matrix with the affinities between items for a set of transactions.

Usage

affinity(x)

Arguments

x

a matrix or an object of class itemMatrix or transactions.

Details

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

A(i,j) = sup({i,j})/(sup({i}) + sup({j}) - sup({i,j})),

where sup(.) is the support measure. This means that affinity is 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

Examples

data("Adult")

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

a <- affinity(s)
image(a)

arules

Mining Association Rules and Frequent Itemsets

v1.6-7
GPL-3
Authors
Michael Hahsler [aut, cre, cph], Christian Buchta [aut, cph], Bettina Gruen [aut, cph], Kurt Hornik [aut, cph], Ian Johnson [ctb, cph], Christian Borgelt [ctb, cph]
Initial release
2021-03-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.