Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

Commit 4f8f03c

Browse files
fix: label ensemble predictions as ENSEMBLE instead of COMMON_NEIGHBORS (#24)
Add ENSEMBLE value to Method enum and use it in predictEnsemble() for both PredictedLink and PredictionResult construction. Previously, ensemble predictions were incorrectly tagged as COMMON_NEIGHBORS, making it impossible to distinguish them from actual common neighbor scores. Fixes #23
1 parent f7e964c commit 4f8f03c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Gvisual/src/gvisual/LinkPredictionAnalyzer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public enum Method {
5656
/** Sum of 1/log(degree) for each common neighbor. */
5757
ADAMIC_ADAR,
5858
/** Product of the two nodes' degrees. */
59-
PREFERENTIAL_ATTACHMENT
59+
PREFERENTIAL_ATTACHMENT,
60+
/** Weighted average across multiple prediction methods. */
61+
ENSEMBLE
6062
}
6163

6264
// ── Result classes ──────────────────────────────────────────
@@ -275,7 +277,7 @@ public PredictionResult predictEnsemble(int topK) {
275277

276278
String[] verts = pairVertices.get(entry.getKey());
277279
candidates.add(new PredictedLink(verts[0], verts[1], avg,
278-
Method.COMMON_NEIGHBORS, pairCommon.get(entry.getKey())));
280+
Method.ENSEMBLE, pairCommon.get(entry.getKey())));
279281
}
280282

281283
Collections.sort(candidates, new Comparator<PredictedLink>() {
@@ -289,7 +291,7 @@ public int compare(PredictedLink a, PredictedLink b) {
289291
0, Math.min(topK, candidates.size()));
290292

291293
return new PredictionResult(new ArrayList<PredictedLink>(top),
292-
Method.COMMON_NEIGHBORS, n, existingEdges, possibleEdges, evaluated);
294+
Method.ENSEMBLE, n, existingEdges, possibleEdges, evaluated);
293295
}
294296

295297
// ── Scoring functions ───────────────────────────────────────

0 commit comments

Comments
 (0)