dissimilarity.html

来自「本程序是基于linux系统下c++代码」· HTML 代码 · 共 160 行

HTML
160
字号
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Dissimilarity Computation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>

<table width="100%" summary="page for dissimilarity {arules}"><tr><td>dissimilarity {arules}</td><td align="right">R Documentation</td></tr></table>
<h2>Dissimilarity Computation</h2>


<h3>Description</h3>

<p>
Provides the generic function <code>dissimilarity</code> and the S4 methods to
compute and returns distances for binary data in a <code>matrix</code>,
<code><a href="transactions-class.html">transactions</a></code> or <code><a href="associations-class.html">associations</a></code>.
</p>


<h3>Usage</h3>

<pre>
dissimilarity(x, y = NULL, method = NULL, args = NULL, ...)
## S4 method for signature 'itemMatrix':
dissimilarity(x, y = NULL, method = NULL, args = NULL,
        which = "transactions")
## S4 method for signature 'associations':
dissimilarity(x, y = NULL, method = NULL, args = NULL,
        which = "transactions")
## S4 method for signature 'matrix':
dissimilarity(x, y = NULL, method = NULL, args = NULL)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
the set of elements (e.g., <code>matrix, itemMatrix, transactions, 
    itemsets, rules</code>). </td></tr>
<tr valign="top"><td><code>y</code></td>
<td>
<code>NULL</code> or a second set to calculate cross dissimilarities. </td></tr>
<tr valign="top"><td><code>method</code></td>
<td>
the distance measure to be used. Implemented measures
are (defaults to <code>"jaccard"</code>):
<dl>
<dt><code>"jaccard"</code>:</dt><dd>the number of items which occur in both 
elements divided by the total number of items in the 
elements (Sneath, 1957). 
This measure is often 
also called: <EM>binary, asymmetric binary,</EM> etc. </dd>
<dt><code>"matching"</code>:</dt><dd>the <EM>Matching coefficient</EM> defined
by Sokal and Michener (1958). This coefficient gives the same
weigth to presents and absence of items.</dd>
<dt><code>"dice"</code>:</dt><dd>the <EM>Dice's coefficient</EM> defined
by Dice (1945). Similar to <EM>Jaccard</EM> but gives double the
weight to agreeing items.</dd>
<dt><code>"cosine"</code>:</dt><dd>the <EM>cosine</EM> distance.</dd> 
<dt><code>"affinity"</code>:</dt><dd>measure based on 
the <code><a href="affinity.html">affinity</a></code></dd>,
a similarity measure between items. It is defined as the
average <EM>affinity</EM> between the items in two transactions 
(see Aggarwal et al. (2002)).</dl>
</td></tr>
<tr valign="top"><td><code>args</code></td>
<td>
a list of additional arguments for the methods.  
<br>
For calculating
<code>"affinity"</code> for associations, the affinities between the items in 
the transactions are needed and passed to the method as the first 
element in <code>args</code>.</td></tr>
<tr valign="top"><td><code>which</code></td>
<td>
a character string indicating if the dissimilarity should be 
calculated between transavtions (default) or items (use <code>"items"</code>). </td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
further arguments.</td></tr>
</table>

<h3>Value</h3>

<p>
returns an object of class <code>dist</code>.</p>

<h3>References</h3>

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


<h3>See Also</h3>

<p>
<code><a href="affinity.html">affinity</a></code>,
<code><a href="proximity-classes.html">dist-class</a></code>,
<code><a href="itemMatrix-class.html">itemMatrix-class</a></code>,
<code><a href="associations-class.html">associations-class</a></code>.
</p>


<h3>Examples</h3>

<pre>
## cluster items in Groceries with support &gt; 5%
data("Groceries")

s &lt;- Groceries[,itemFrequency(Groceries)&gt;0.05]
d_jaccard &lt;- dissimilarity(s, which = "items")
plot(hclust(d_jaccard, method = "ward"))


## cluster transactions for a sample of Adult
data("Adult")
s &lt;- sample(Adult, 200) 

##  calculate Jaccard distances and do hclust
d_jaccard &lt;- dissimilarity(s)
plot(hclust(d_jaccard))

## calculate affinity-based distances and do hclust
d_affinity &lt;- dissimilarity(s, method = "affinity")
plot(hclust(d_affinity))

## cluster rules
rules &lt;- apriori(Adult)
rules &lt;- subset(rules, subset = lift &gt; 2)

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



<hr><div align="center">[Package <em>arules</em> version 0.6-6 <a href="00Index.html">Index]</a></div>

</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?