2017-04-14 3 views
0

Wie würden Sie in Cypher k-means ändern, um den Jaccard-Abstand Dj anstelle des euklidischen Abstands zu berücksichtigen?Jaccard in k-means Clustering

Wo Jaccard Entfernung als Dj definiert = 1- (| A∩B |)/(| A∪B |)

+0

überprüfen Sie diese Grafikkarte http://neo4j.com/graphgist/49a2b9874b37b4a2da4a/ –

Antwort

0

Hier ist ein Beispiel dafür, wie Jaccard Abstand mit Cypher zu berechnen (aus den Recommendations Neoj Sandbox):

MATCH (m:Movie {title: "Inception"})-[:IN_GENRE]->(g:Genre)<-[:IN_GENRE]-(other:Movie) 
WITH m, other, COUNT(g) AS intersection, COLLECT(g.name) AS i 
MATCH (m)-[:IN_GENRE]->(mg:Genre) 
WITH m,other, intersection,i, COLLECT(mg.name) AS s1 
MATCH (other)-[:IN_GENRE]->(og:Genre) 
WITH m,other,intersection,i, s1, COLLECT(og.name) AS s2 
WITH m,other,intersection,s1,s2 
WITH m,other,intersection,s1+filter(x IN s2 WHERE NOT x IN s1) AS union, s1, s2 
RETURN m.title, other.title, s1,s2,((1.0*intersection)/SIZE(union)) AS jaccard ORDER BY jaccard DESC LIMIT 100 

Sobald Sie berechnen, können Sie es mit Ihrem k-Means-Algorithmus verwenden. Wie laufen Sie k-Mittel? Auch in Cypher?

+0

Vielen Dank! Ja, das wird alles eine neo4j Abfrage sein. – ProdBot