MCPcopy Create free account
hub / github.com/antlr/codebuff / kNN

Method kNN

src/org/antlr/codebuff/kNNClassifier.java:226–231  ·  view source on GitHub ↗
(int[] unknown, int k, double distanceThreshold)

Source from the content-addressed store, hash-verified

224 }
225
226 public Neighbor[] kNN(int[] unknown, int k, double distanceThreshold) {
227 Neighbor[] distances = distances(unknown, k, distanceThreshold);
228 Arrays.sort(distances,
229 (Neighbor o1, Neighbor o2) -> Double.compare(o1.distance, o2.distance));
230 return Arrays.copyOfRange(distances, 0, Math.min(k, distances.length));
231 }
232
233 public Neighbor[] distances(int[] unknown, int k, double distanceThreshold) {
234 int curTokenRuleIndex = unknown[Trainer.INDEX_PREV_EARLIEST_RIGHT_ANCESTOR];

Callers 3

classifyMethod · 0.95
votesMethod · 0.95
getPredictionAnalysisMethod · 0.95

Calls 4

distancesMethod · 0.95
sortMethod · 0.80
compareMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected