Learn R Programming

arules (version 0.2-6)

dissimilarity: Dissimilarity Computation

Description

Provides the generic function dissimilarity and the S4 methods to compute and returns distances for binary data in a matrix, transactions or associations.

Usage

dissimilarity(x, y = NULL, method = NULL, args = NULL)
## S3 method for class 'itemMatrix':
dissimilarity(x, y = NULL, method = NULL, args = NULL)
## S3 method for class 'associations':
dissimilarity(x, y = NULL, method = NULL, args = NULL)
## S3 method for class 'matrix':
dissimilarity(x, y = NULL, method = NULL, args = NULL)

Arguments

x
the set of elements (e.g., matrix, itemMatrix, transactions, itemsets, rules).
y
NULL or a second set to calculate cross dissimilarities.
method
the distance measure to be used. Implemented measures are (defaults to "Jaccard"): [object Object],[object Object],[object Object],[object Object],, a similarity measure between items. It is defined as the average a
args
a list of additional arguments for the methods. For calculating "Affinity" for associations, the affinities between the items in the transactions are needed and passed to the method as the first element in arg

Value

  • returns an object of class dist.

References

Sneath, P. H. A. Some thoughts on bacterial classification. Journal of General Microbiology 17, pages 184-200, 1957. Sokal, R. R. and Michener, C. D. A statistical method for evaluating systematic relationships. University of Kansas Science Bulletin 38, pages 1409-1438, 1958 Dice, L. R. Measures of the amount of ecologic association between species. Ecology 26, pages 297-302, 1945. Charu C. Aggarwal, Cecilia Procopiuc, and Philip S. Yu. Finding localized associations in market basket data. IEEE Trans. on Knowledge and Data Engineering, 14(1), pages 51-62, 2002.

See Also

affinity, dist-class, itemMatrix-class, associations-class.

Examples

Run this code
data("Adult")

## cluster transactions
## choose a sample 
s <- sample(Adult, 500) 

##  calculate Jaccard distances and do hclust
d_jaccard <- dissimilarity(s)
plot(hclust(d_jaccard))

## calculate affinity-based distances and do hclust
d_affinity <- dissimilarity(s, method = "Affinity")
plot(hclust(d_affinity))


## cluster rules
## mine rules
rules <- apriori(Adult)
## choose promising rules
rules <- subset(rules, subset = lift > 2)

## we need to supply the item affinities from the dataset (sample)
d_affinity <- dissimilarity(rules, method = "Affinity", 
  args = list(affinity = affinity(s)))
plot(hclust(d_affinity))

Run the code above in your browser using DataLab