mirror of
https://github.com/twitter/the-algorithm.git
synced 2025-01-24 18:01:16 +01:00
Merge 1a73a64b197035aea1b2ff9c4329a3f39886fb84 into fb54d8b54984f89f7dba90a18e7c3048421464c3
This commit is contained in:
commit
e839fe55ec
@ -90,21 +90,14 @@ object ClusterEvaluation {
|
||||
val resultsIter = membersAdjLists.flatMap {
|
||||
case (fromNodeId, adjList) =>
|
||||
val fromNodeWt = memberScores.getOrElse(fromNodeId, 0.0)
|
||||
adjList.map {
|
||||
case (toNodeId, edgeWt) =>
|
||||
if (memberScores.contains(toNodeId)) {
|
||||
val productOfMembershipScores = fromNodeWt * memberScores(toNodeId)
|
||||
ClusterResults(
|
||||
1,
|
||||
edgeWt,
|
||||
0,
|
||||
0,
|
||||
samplerMonoid.build(
|
||||
((fromNodeId, toNodeId), (edgeWt.toDouble, productOfMembershipScores))))
|
||||
} else {
|
||||
ClusterResults(0, 0, 1, edgeWt, samplerMonoid.zero)
|
||||
}
|
||||
}
|
||||
adjList.map(ad => ad match {
|
||||
case (toNodeId,edgeWt) if (!memberScores.contains(toNodeId)) =>
|
||||
ClusterResults(0, 0, 1, edgeWt, samplerMonoid.zero)
|
||||
case (toNodeId,edgeWt) =>
|
||||
val productOfMembershipScores = fromNodeWt * memberScores(toNodeId)
|
||||
val sampler = samplerMonoid.build((fromNodeId, toNodeId), (edgeWt.toDouble, productOfMembershipScores))
|
||||
ClusterResults(1, edgeWt, 0, 0, sampler)
|
||||
})
|
||||
}
|
||||
Monoid.sum(resultsIter)(ClusterResultsMonoid)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user