Description Usage Arguments Details Value See Also Examples
Calculate the similarity between two vectors of logicals.
1 | similarity(x, y, measure)
|
x, y |
Logical or numeric vectors. |
measure |
Similarity measure ("simple_matching", "jaccard", or "tanimoto") |
Input vectors must consist of logical or numeric elements TRUE,FALSE or 0,1 (not factors). Similarity measures in this package are based on those defined in the PMML specification. Similarity ranges from 0 (no similarity) to 1 (identical).
For logical vectors x
and y
, we define the following:
a11
= number of times where x_i=1 and y_i=1
a10
= number of times where x_i=1 and y_i=0
a01
= number of times where x_i=0 and y_i=1
a00
= number of times where x_i=0 and y_i=0
Similarities are calculated using the following formulas:
Simple matching: (a11 + a00) / (a11 + a10 + a01 + a00)
Jaccard: (a11) / (a11 + a10 + a01)
Tanimoto: (a11 + a00) / (a11 + 2 * (a10 + a01) + a00)
The similarity between x
and y
.
distance
,
PMML comparison measures
1 2 3 | similarity(c(0,1,1),c(0,0,1),"simple_matching")
similarity(c(0,1,1),c(0,0,1),"jaccard")
similarity(as.logical(c(0,1,1)),as.logical(c(0,0,1)),"tanimoto")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.