2017-04-14 1 views
0

Cypher에서 유클리드 거리가 아닌 Jaccard 거리 Dj를 고려하기 위해 k-means를 어떻게 수정 하시겠습니까?Jaccard in k-means clustering

인 Jaccard 거리 디제이 = 1로 정의된다

(| A∪B |) (| | A∩B)/

+0

체크 graphgist http://neo4j.com/graphgist/49a2b9874b37b4a2da4a/ –

답변

0

여기합니다 (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- 평균 알고리즘을 사용하면이를 계산할 수 있습니다. 어떻게 k 평균을 달리고 있니? Cypher에서도?

+0

고마워요! 예,이 모든 것이 결국에는 neo4j 쿼리가됩니다. – ProdBot