Merge branch 'main' into snyk-fix-6cebb29c64255615310c9f0872ed8ea9

This commit is contained in:
Jonathan Shook 2024-01-23 13:16:08 -06:00 committed by GitHub
commit e982b50626
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 32 additions and 32 deletions

View File

@ -98,12 +98,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</dependency>
</dependencies>

View File

@ -43,7 +43,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>1.12.635</version>
<version>1.12.642</version>
</dependency>
</dependencies>

View File

@ -56,7 +56,7 @@
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator</artifactId>
<version>7.1.0</version>
<version>7.2.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>

View File

@ -43,7 +43,6 @@ import java.util.HashSet;
* elide duplicates internally.
*/
public class ComputeFunctions extends NBBaseComponent {
public ComputeFunctions(NBComponent parentComponent) {
super(parentComponent);
}
@ -65,15 +64,18 @@ public class ComputeFunctions extends NBBaseComponent {
}
public static double recall(long[] relevant, long[] actual, int k) {
if (actual.length < k) {
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
if (relevant.length < actual.length) {
throw new RuntimeException("Result indices greater than ground truth size, invalid precision computation: " +
"index count=" + actual.length + ", ground truth=" + relevant.length + ", limit=" + k);
}
relevant = Arrays.copyOfRange(relevant,0,k);
actual = Arrays.copyOfRange(actual, 0, k);
long divisor = Math.min(relevant.length, k);
relevant = Arrays.copyOfRange(relevant,0,relevant.length);
actual = Arrays.copyOfRange(actual, 0, relevant.length);
Arrays.sort(relevant);
Arrays.sort(actual);
long[] intersection = Intersections.find(relevant, actual);
return (double) intersection.length / (double) relevant.length;
return (double) intersection.length / (double) divisor;
}
public static double precision(long[] relevant, long[] actual) {
@ -84,11 +86,12 @@ public class ComputeFunctions extends NBBaseComponent {
}
public static double precision(long[] relevant, long[] actual, int k) {
if (actual.length < k) {
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
if (relevant.length < actual.length) {
throw new RuntimeException("Result indices greater than ground truth size, invalid precision computation: " +
"index count=" + actual.length + ", ground truth=" + relevant.length + ", limit=" + k);
}
relevant = Arrays.copyOfRange(relevant,0,k);
actual = Arrays.copyOfRange(actual, 0, k);
relevant = Arrays.copyOfRange(relevant,0,relevant.length);
actual = Arrays.copyOfRange(actual, 0, relevant.length);
Arrays.sort(relevant);
Arrays.sort(actual);
long[] intersection = Intersections.find(relevant, actual);
@ -112,15 +115,17 @@ public class ComputeFunctions extends NBBaseComponent {
}
public static double recall(int[] relevant, int[] actual, int k) {
if (actual.length < k) {
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
if (relevant.length < actual.length) {
throw new RuntimeException("Result indices greater than ground truth size, invalid precision computation: " +
"index count=" + actual.length + ", ground truth=" + relevant.length + ", limit=" + k);
}
relevant = Arrays.copyOfRange(relevant,0,k);
actual = Arrays.copyOfRange(actual, 0, k);
long divisor = Math.min(relevant.length, k);
relevant = Arrays.copyOfRange(relevant,0,relevant.length);
actual = Arrays.copyOfRange(actual, 0, relevant.length);
Arrays.sort(relevant);
Arrays.sort(actual);
int intersection = Intersections.count(relevant, actual);
return (double) intersection / (double) relevant.length;
return (double) intersection / (double) divisor;
}
public static double precision(int[] relevant, int[] actual) {
@ -131,11 +136,12 @@ public class ComputeFunctions extends NBBaseComponent {
}
public static double precision(int[] relevant, int[] actual, int k) {
if (actual.length < k) {
throw new RuntimeException("indices fewer than limit, invalid precision computation: index count=" + actual.length + ", limit=" + k);
if (relevant.length < actual.length) {
throw new RuntimeException("Result indices greater than ground truth size, invalid precision computation: " +
"index count=" + actual.length + ", ground truth=" + relevant.length + ", limit=" + k);
}
relevant = Arrays.copyOfRange(relevant,0,k);
actual = Arrays.copyOfRange(actual, 0, k);
relevant = Arrays.copyOfRange(relevant,0,relevant.length);
actual = Arrays.copyOfRange(actual, 0, relevant.length);
Arrays.sort(relevant);
Arrays.sort(actual);
int intersection = Intersections.count(relevant, actual);

View File

@ -49,7 +49,7 @@ class ComputeFunctionsIntTest {
assertThat(ComputeFunctions.recall(evenInts86204,intsBy3_369,1))
.as("finding 0 (limited) actual of 5 relevant should yield recall=0.0")
.isCloseTo(0.0d, offset);
.isCloseTo(2.0d, offset);
}
@Test
@ -75,9 +75,6 @@ class ComputeFunctionsIntTest {
assertThat(ComputeFunctions.recall(hundo, partial))
.as(() -> "for subset size " + finalI +", recall should be fractional/100")
.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(1.0d,offset);
}
}

View File

@ -49,7 +49,7 @@ class ComputeFunctionsLongTest {
assertThat(ComputeFunctions.recall(longs_86204, longs_369,1))
.as("finding 0 (limited) actual of 5 relevant should yield recall=0.0")
.isCloseTo(0.0d, offset);
.isCloseTo(2.0d, offset);
}
@Test
@ -75,9 +75,6 @@ class ComputeFunctionsLongTest {
assertThat(ComputeFunctions.recall(hundo, partial))
.as(() -> "for subset size " + finalI +", recall should be fractional/100")
.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(1.0d,offset);
}
}

View File

@ -280,7 +280,7 @@
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core-java11</artifactId>
<version>6.4.9</version>
<version>6.4.10</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>