Hey,
If you want to calculate similarity based on overlap of items, I think the Jaccard Similarity algorithm might be a better choice - Similarity functions - Neo4j Graph Data Science
The Euclidean (and Cosine/Pearson) algorithm would make more sense if you were doing something like comparing the ratings that different people had given to shows so that you can compare their tastes.
From playing around with Euclidean, I realise that a score of 0 could mean the scores are identical but it could also mean there's no overlap at all.
RETURN algo.similarity.euclideanDistance([7,7,7], [7,7,7]) AS similarity1,
algo.similarity.euclideanDistance([7,8,7], [8,8,7]) AS similarity2,
algo.similarity.euclideanDistance([1,1,1], [7,7,7]) AS similarity3
You can also see on the results below that similarity3, where the scores are less similar, has a higher value than the other two comparisons:
βββββββββββββββ€ββββββββββββββ€βββββββββββββββββββ
β"similarity1"β"similarity2"β"similarity3" β
βββββββββββββββͺββββββββββββββͺβββββββββββββββββββ‘
β0.0 β1.0 β10.392304845413264β
βββββββββββββββ΄ββββββββββββββ΄βββββββββββββββββββ
And then this one has no overlap:
WITH [
{item: 1, weights: [algo.NaN(),2,algo.NaN()]},
{item: 2, weights: [1,algo.NaN(),4]}
] AS data
CALL algo.similarity.euclidean.stream(data)
YIELD item1, item2, count1, count2, similarity
RETURN item1 AS from, item2 AS to, similarity
ORDER BY similarity
Also has a score of 0:
ββββββββ€βββββ€βββββββββββββ
β"from"β"to"β"similarity"β
ββββββββͺβββββͺβββββββββββββ‘
β1 β2 β0.0 β
ββββββββ΄βββββ΄βββββββββββββ
We probably need to see what other libraries do about this type of situation - should we be returning a null similarity if there's no overlap between the arrays? I'm not sure!