in src/main/java/com/twitter/sbf/core/MHAlgorithm.java [732:769]
public static void evalClusterPrecision(
Graph graph,
SparseBinaryMatrix matrix,
String outputFile,
int cpu) throws IOException {
double[] clusterPrecision = new double[matrix.getNumCols()];
ExecutorService executor = Executors.newFixedThreadPool(cpu);
for (Range range : Util.chunkArray(matrix.getNumCols(), 1000)) {
executor.submit(() -> {
for (int k = range.start; k < range.end; k++) {
IntSet col = matrix.getColumn(k);
double wtTruePositive = 0;
double wtPositive = 0;
// SUPPRESS CHECKSTYLE NestedForDepth
for (int v1 : col) {
// SUPPRESS CHECKSTYLE NestedForDepth
for (int v2 : col) {
if (v1 < v2) {
double edgeWt = graph.getWeightOfEdge(v1, v2);
wtTruePositive += edgeWt;
wtPositive += edgeWt > 0 ? edgeWt
: (graph.getWeightedOutDegree(v1) + graph.getWeightedOutDegree(v2))
/ (graph.getDegree(v1) + graph.getDegree(v2));
}
}
}
clusterPrecision[k] = wtPositive > 0 ? wtTruePositive / wtPositive : 0.0;
}
});
}
executor.shutdown();
try {
executor.awaitTermination(60, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
Util.appendDoublesToFile(outputFile, clusterPrecision);
}