Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit 01ca80f

Browse files
davidoliverSP2mneedham
authored andcommitted
Add the missing images to the similarity algorithm docs (#714)
* add cosine images * add Jaccard image * replace euclidean with wiki version
1 parent 4979085 commit 01ca80f

File tree

7 files changed

+13
-6
lines changed

7 files changed

+13
-6
lines changed

doc/asciidoc/similarity-cosine.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ include::scripts/similarity-cosine.cypher[tag=function]
6565
These two lists of numbers have a Cosine similarity of 0.863.
6666
We can see how this result is derived by breaking down the formula:
6767

68-
// Turn this into an image
68+
image::cosine-similarity2.png[role="middle"]
69+
70+
// This is the raw information for this image:
6971
// [subs = none]
7072
// \( similarity(A, B) = \frac{3 \cdot 10 + 8 \cdot 8 + 7 \cdot 6 + 5 \cdot 6 + 2 \cdot 4 + 9 \cdot 5}{\sqrt{3^2 + 8^2 + 7^2 + 5^2 + 2^2 + 9^2} \times \sqrt{10^2 + 8^2 + 6^2 + 6^2 + 4^2 + 5^2}} = \frac{219}{15.2315 \times 16.6433} = 0.8639 \)
7173

doc/asciidoc/similarity-euclidean.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ Euclidean distance measures the straight line distance between two points in n-d
1818

1919
Euclidean distance is computed using the following formula:
2020

21-
// // Turn this into an image
21+
image::euclidean.png[role="middle"]
22+
23+
// This is the raw information for this image:
2224
// [subs = none]
2325
// \( similarity(p_1, p_2) = \sqrt{\sum_{i~\in~\textrm{item}} (s_{p_1} - s_{p_2})^2} \)
2426

doc/asciidoc/similarity-jaccard.adoc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ It is defined as the size of the intersection divided by the size of the union o
1919

2020
Jaccard similarity is computed using the following formula:
2121

22-
```
23-
J(A,B) = ∣A ∩ B∣ / ∣(A ∪ B)∣
24-
= ∣A ∩ B∣ / ∣A∣ + ∣B∣ - ∣A ∩ B|
25-
```
22+
image::jaccard.png[role="middle"]
23+
24+
// This is the raw information for this image:
25+
// ```
26+
// J(A,B) = ∣A ∩ B∣ / ∣(A ∪ B)∣
27+
// = ∣A ∩ B∣ / ∣A∣ + ∣B∣ - ∣A ∩ B|
28+
// ```
2629

2730
The library contains both procedures and functions to calculate similarity between sets of data.
2831
The function is best used when calculating the similarity between small numbers of sets.

doc/images/cosine-similarity.png

-16.2 KB
Loading

doc/images/cosine-similarity2.png

13.3 KB
Loading

doc/images/euclidean.png

11.6 KB
Loading

doc/images/jaccard.png

16.7 KB
Loading

0 commit comments

Comments
 (0)