# Jaccard in Alpha forever

**URL:** <https://community.neo4j.com/t/jaccard-in-alpha-forever/34885>\
**Category:** Graph Data Science / Graph Analytics\
**Created:** [March 8, 2021, 10:51pm UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885 "2021-03-08T22:51:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![stu\_v\_kerr](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stu_v_kerr/32/691_2.png) [@stu\_v\_kerr](https://community.neo4j.com/u/stu_v_kerr)\
**Post date:** [March 8, 2021, 10:51pm UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885/1 "2021-03-08T22:51:47Z")

</div>

So I was a big fan of Neo4j v 3.4.12 and the state of graph algorithms there; in particular Jaccard Similarity. Ever since upgrading, the gds library has had Jaccard in Alpha status.

Question for Alicia and her team: Are you moving everyone over to Node Similarity? And Jaccard will eventually be deprecated?

Thanks.

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [March 9, 2021, 5:52am UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885/2 "2021-03-09T05:52:04Z")

</div>

Check this link especially recent update by abk.

> [@Graph Algorithms Book Not Finding Similarity Algorithms](https://community.neo4j.com/t/graph-algorithms-book-not-finding-similarity-algorithms/7879/2):
>
> I don't believe these are covered in the book. I believe the explanation was that although they can be useful in a graph context, they aren't really graph algorithms (they work on vector inputs). This omission is mentioned in the Other Algorithms section: Other Algorithms Many algorithms can be used with graph data. In this book, we’ve focused on those that are most representative of classic graph algorithms and those of most use to application developers. Some algorithms, such as coloring …

---

<div class="post-metadata">

**Author:** ![markhneedham](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/markhneedham/32/16986_2.png) [@markhneedham](https://community.neo4j.com/u/markhneedham)\
**Post date:** [March 9, 2021, 7:13am UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885/3 "2021-03-09T07:13:43Z")

</div>

I think we've found that the node similarity procedure solved better solved the problem that users had than the Jaccard one.  
  
With Jaccard you had to build up lists of arrays before computing, whereas with node similarity it computes it based on the graph structure. And the majority of users can solve their problems with node similarity.  
  
Do you have some old code that uses Jaccard n Graph Algos and you're trying to translate it to GDS? Perhaps I can help you translate it if you share the query.

---

<div class="post-metadata">

**Author:** ![alicia\_frame1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/alicia_frame1/32/6998_2.png) [@alicia\_frame1](https://community.neo4j.com/u/alicia_frame1)\
**Post date:** [March 9, 2021, 7:53pm UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885/4 "2021-03-09T19:53:38Z")

</div>

We do consider Jaccard part of the algorithms library, but as you correctly guess, and @markhneedham explained - for performance at scale, Node Similarity or KNN are better choices than Jaccard or Cosine similarity. Node similarity uses the jaccard similarity metric, but it leverages neighboring nodes instead of properties or lists.  
  
We don't have any plans to deprecate or remove Jaccard, but we're not currently working on promoting it to the beta tier. Do you have a use case that can't be addressed with Node Similarity?

---

<div class="post-metadata">

**Author:** ![stu\_v\_kerr](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stu_v_kerr/32/691_2.png) [@stu\_v\_kerr](https://community.neo4j.com/u/stu_v_kerr)\
**Post date:** [March 9, 2021, 11:04pm UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885/5 "2021-03-09T23:04:05Z")

</div>

> [@stu\_v\_kerr](#):
>
> So I was a big fan of Neo4j v 3.4.12 and the state of graph algorithms there; in particular Jaccard Similarity. Ever since upgrading, the gds library has had Jaccard in Alpha status.
> 
> Question for Alicia and her team: Are you moving everyone over to Node Similarity? And Jaccard will eventually be deprecated?

Mark: Here is the query. Determining similarity via Jaccard of "Song" nodes....

```auto
MATCH (Guest{member:'Purple'})-[:PLAYS_SONG]->(t:Song)
WITH {item:id(t), categories: collect(id(Guest))} as userData
WITH collect(userData) as data
CALL algo.similarity.jaccard(data, {similarityCutoff:0.2, write:true, writeRelationshipType:'SIMILAR_PURPLE', writeProperty:'score_purple'})
YIELD nodes, similarityPairs, stdDev, p25, p50, p75, p90, p95
RETURN nodes, similarityPairs, stdDev, p25, p50, p75, p90, p95

```

---

<div class="post-metadata">

**Author:** ![stu\_v\_kerr](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stu_v_kerr/32/691_2.png) [@stu\_v\_kerr](https://community.neo4j.com/u/stu_v_kerr)\
**Post date:** [March 9, 2021, 11:48pm UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885/6 "2021-03-09T23:48:16Z")

</div>

Also, since now i will be using gds 1.1.1 and using graph projections, I don't seem to be able to create a graph projection where i reduce the size of the projection filtering on node properties. I see the template below, but i seem unable to

---

<div class="post-metadata">

**Author:** ![stu\_v\_kerr](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stu_v_kerr/32/691_2.png) [@stu\_v\_kerr](https://community.neo4j.com/u/stu_v_kerr)\
**Post date:** [March 9, 2021, 11:49pm UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885/7 "2021-03-09T23:49:29Z")

</div>

...continuing. using the template below, i seem unable to filter the projection based upon node properties:

```auto
CALL gds.graph.create(
    'my-graph', {
        City: {
            properties: {
                stateId: {
                    property: 'stateId' SAY WHERE 'STATEID' = "CA"
                },
                population: {
                    property: 'population'
                }
            }
        }
    },
    '*'
)
YIELD graphName, nodeCount, relationshipCount;

```

---

<div class="post-metadata">

**Author:** ![markhneedham](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/markhneedham/32/16986_2.png) [@markhneedham](https://community.neo4j.com/u/markhneedham)\
**Post date:** [March 10, 2021, 11:06am UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885/8 "2021-03-10T11:06:56Z")

</div>

So for your first query, you can compute the similarity between all guests like this:

```auto
CALL gds.nodeSimilarity.stream({
  nodeProjection: ['Guest', 'Song'],
  relationshipProjection: "PLAYS_SONG"
})
YIELD node1, node2, similarity
RETURN gds.util.asNode(node1) AS node1,
       gds.util.asNode(node2) AS node2,
       similarity

```

And then if you wanted to create a graph first it'd look like this instead:  
  
Create graph:

```auto
CALL gds.graph.create(
    'myGraph',
    ['Guest', 'Song'],
    "PLAYS_SONG"
);

```

Run algorithm:

```auto
CALL gds.nodeSimilarity.stream("myGraph")
YIELD node1, node2, similarity
RETURN gds.util.asNode(node1) AS node1,
       gds.util.asNode(node2) AS node2,
       similarity

```

---

<div class="post-metadata">

**Author:** ![stu\_v\_kerr](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stu_v_kerr/32/691_2.png) [@stu\_v\_kerr](https://community.neo4j.com/u/stu_v_kerr)\
**Post date:** [March 10, 2021, 1:31pm UTC](https://community.neo4j.com/t/jaccard-in-alpha-forever/34885/9 "2021-03-10T13:31:54Z")

</div>

Thank you very much Mark. One other issue:  
In our graph model, there exists \> 2.6 million Guests. To reduce the size of a graph projection and reduce the memory footprint, we wish to filter the Guests based on a particular node property (call it 'tier'). I have been reviewing the documentation and the only possible method is to use a parameter identifying the value of 'tier' that we wish to filter? Is this correct or is there another way?  
Thank you again.
