0
在Cypher中,如何修改k-means來考慮Jaccard距離Dj而不是歐幾里得距離?k-means聚類中的Jaccard
在哪裏的Jaccard距離被定義爲了Dj = 1-(|A∩B|)/(|A∪B|)
在Cypher中,如何修改k-means來考慮Jaccard距離Dj而不是歐幾里得距離?k-means聚類中的Jaccard
在哪裏的Jaccard距離被定義爲了Dj = 1-(|A∩B|)/(|A∪B|)
下面是如何計算與CYPHER(從Recommendations Neoj Sandbox)的Jaccard距離的例子:
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
一旦你計算出你可以使用它與你的k-means算法。你如何運行k-means?還在Cypher中?
非常感謝!是的,這將最終都是一個neo4j查詢。 – ProdBot
檢查此圖表:http://neo4j.com/graphgist/49a2b9874b37b4a2da4a/ –