mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-12-22 10:11:52 +01:00
Merge e1691d5f25
into 72eda9a24f
This commit is contained in:
commit
7382d72eaa
@ -120,15 +120,15 @@ object UpdateKnownFor {
|
||||
clusterScoresToFinalScore: ClusterScoresForNode => Double,
|
||||
minNeighborsInCluster: Int
|
||||
): Option[(Int, Double)] = {
|
||||
val clusterToScores = statsOfClustersInNeighborhood.toList.flatMap {
|
||||
statsOfClustersInNeighborhood
|
||||
.toList
|
||||
.flatMap {
|
||||
case (clusterId, statsInNeighborhood) =>
|
||||
val clusterOverallStats = clusterOverallStatsMap(clusterId)
|
||||
if (statsInNeighborhood.nodeCount >= minNeighborsInCluster) {
|
||||
Some(
|
||||
(
|
||||
clusterId,
|
||||
clusterScoresToFinalScore(
|
||||
getScoresForCluster(
|
||||
statsInNeighborhood match {
|
||||
case statsInNeighborhood if statsInNeighborhood.nodeCount < minNeighborsInCluster => None
|
||||
case _ =>
|
||||
val score = getScoresForCluster(
|
||||
overallNeighborhoodStats,
|
||||
statsInNeighborhood,
|
||||
clusterOverallStats.nodeCount,
|
||||
@ -136,16 +136,12 @@ object UpdateKnownFor {
|
||||
globalAvgEdgeWeight,
|
||||
truePositiveWtFactor
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
None
|
||||
Some((clusterId, clusterScoresToFinalScore(score)))
|
||||
}
|
||||
} match {
|
||||
case scores if scores.isEmpty => None
|
||||
case _ => Some(clusterToScores.maxBy(_._2))
|
||||
}
|
||||
if (clusterToScores.nonEmpty) {
|
||||
Some(clusterToScores.maxBy(_._2))
|
||||
} else None
|
||||
}
|
||||
|
||||
def updateGeneric(
|
||||
@ -170,10 +166,11 @@ object UpdateKnownFor {
|
||||
collectInformationPerNode(graph, inputUserToClusters, avgMembershipScore)
|
||||
.mapValues {
|
||||
case NodeInformation(originalClusters, overallStats, statsOfClustersInNeighborhood) =>
|
||||
val newClusterWithScoreOpt = if (overallStats.nodeCount < minNeighborsInCluster) {
|
||||
overallStats match {
|
||||
case stats if (overallStats.nodeCount < minNeighborsInCluster) =>
|
||||
nodesWithSmallDegree.inc()
|
||||
None
|
||||
} else {
|
||||
case _ =>
|
||||
pickBestCluster(
|
||||
overallStats,
|
||||
statsOfClustersInNeighborhood,
|
||||
@ -183,22 +180,18 @@ object UpdateKnownFor {
|
||||
clusterScoresToFinalScore,
|
||||
minNeighborsInCluster
|
||||
)
|
||||
}
|
||||
newClusterWithScoreOpt match {
|
||||
} match {
|
||||
case Some((newClusterId, score)) =>
|
||||
if (originalClusters.isEmpty) {
|
||||
emptyToSomething.inc()
|
||||
} else if (originalClusters.contains(newClusterId)) {
|
||||
sameCluster.inc()
|
||||
} else {
|
||||
diffCluster.inc()
|
||||
originalClusters match {
|
||||
case cluster if cluster.isEmpty => emptyToSomething.inc()
|
||||
case cluster if cluster.contains(newClusterId) => sameCluster.inc()
|
||||
case _ => diffCluster.inc()
|
||||
}
|
||||
Array((newClusterId, score.toFloat))
|
||||
case None =>
|
||||
if (originalClusters.isEmpty) {
|
||||
emptyToEmpty.inc()
|
||||
} else {
|
||||
somethingToEmpty.inc()
|
||||
originalClusters match {
|
||||
case cluster if cluster.isEmpty => emptyToEmpty.inc()
|
||||
case _ => somethingToEmpty.inc()
|
||||
}
|
||||
Array.empty[(Int, Float)]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user