Skip to content
Snippets Groups Projects
Commit 875037df authored by a.croix's avatar a.croix
Browse files

Solve bug. Large dataset produced a negative AUC or an AUC bigger than 1

parent 0457c3cd
No related branches found
No related tags found
1 merge request!2Correct bug
Pipeline #3202 passed
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
...@@ -32,12 +32,12 @@ public final class Main { ...@@ -32,12 +32,12 @@ public final class Main {
System.out.println("PR AUC with trapezoid : " + pr.computePRAUC()); System.out.println("PR AUC with trapezoid : " + pr.computePRAUC());
pr.computePrcPointsAndGenerateCurve("PR_curve.png"); pr.computePrcPointsAndGenerateCurve("PR_curve.png");
double[] long_data = new double[200000]; double[] long_data = new double[250000];
double[] long_alert = new double[long_data.length]; double[] long_alert = new double[long_data.length];
for (int i = 0; i < long_data.length; i++) { for (int i = 0; i < long_data.length; i++) {
long_data[i] = Math.random(); long_data[i] = Math.random();
double trig = Math.random(); double trig = Math.random();
if (trig < 0.2) { if (trig < 0.5) {
long_alert[i] = 0.0; long_alert[i] = 0.0;
} else { } else {
long_alert[i] = 1.0; long_alert[i] = 1.0;
......
...@@ -16,8 +16,8 @@ import java.util.List; ...@@ -16,8 +16,8 @@ import java.util.List;
public class Roc { public class Roc {
private List<Point> points; private List<Point> points;
private int positive_examples_number; private double positive_examples_number;
private int negative_examples_number; private double negative_examples_number;
/** /**
* Constructor of ROC object. * Constructor of ROC object.
......
...@@ -48,4 +48,21 @@ class RocTest { ...@@ -48,4 +48,21 @@ class RocTest {
Roc roc = new Roc("src/main/resources/RocSampleData.csv"); Roc roc = new Roc("src/main/resources/RocSampleData.csv");
assertEquals(auc, roc.computeAUC(), 0.00000001); assertEquals(auc, roc.computeAUC(), 0.00000001);
} }
@Test
void computeAUCWithBigDataset() {
double[] long_data = new double[200000];
double[] long_alert = new double[long_data.length];
for (int i = 0; i < long_data.length; i++) {
long_data[i] = Math.random();
double trig = Math.random();
if (trig < 0.5) {
long_alert[i] = 0.0;
} else {
long_alert[i] = 1.0;
}
}
Roc long_roc = new Roc(long_data, long_alert);
assertTrue(long_roc.computeAUC() < 1.0 && long_roc.computeAUC() > 0.0);
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment