update recall relevant set

This commit is contained in:
Jonathan Shook 2023-10-04 14:43:36 -05:00
parent aa88c22a2c
commit 469985de6e
2 changed files with 4 additions and 2 deletions

View File

@ -61,6 +61,7 @@ public class ComputeFunctions {
if (actual.length < k) {
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
}
relevant = Arrays.copyOfRange(relevant,0,k);
actual = Arrays.copyOfRange(actual, 0, k);
Arrays.sort(relevant);
Arrays.sort(actual);
@ -106,6 +107,7 @@ public class ComputeFunctions {
if (actual.length < k) {
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
}
relevant = Arrays.copyOfRange(relevant,0,k);
actual = Arrays.copyOfRange(actual, 0, k);
Arrays.sort(relevant);
Arrays.sort(actual);

View File

@ -69,7 +69,7 @@ class ComputeFunctionsIntTest {
public void sanityCheckRecallAndLimitRatio() {
int[] hundo = IntStream.range(0,100).toArray();
for (int i = 0; i < hundo.length; i++) {
for (int i = 1; i < hundo.length; i++) {
int[] partial=IntStream.range(0,i).toArray();
int finalI = i;
assertThat(ComputeFunctions.recall(hundo, partial))
@ -77,7 +77,7 @@ class ComputeFunctionsIntTest {
.isCloseTo((double)partial.length/(double)hundo.length,offset);
assertThat(ComputeFunctions.recall(hundo, hundo, i))
.as(() -> "for full intersection, limit " + finalI +" (K) recall should be fractional/100")
.isCloseTo((double)partial.length/(double)hundo.length,offset);
.isCloseTo(1.0d,offset);
}
}