@Override public String toString() { return String.format(Locale.ENGLISH, "auc=%.2f", wrapped.auc()); }
@Override public String toString() { return String.format(Locale.ENGLISH, "auc=%.2f", wrapped.auc()); }
@Override public String toString() { return String.format(Locale.ENGLISH, "auc=%.2f", wrapped.auc()); }
/** * What is the AUC for the current best member of the population. If no member is best, usually * because we haven't done any training yet, then the result is set to NaN. * * @return The AUC of the best member of the population or NaN if we can't figure that out. */ public double auc() { if (best == null) { return Double.NaN; } else { Wrapper payload = best.getPayload(); return payload.getLearner().auc(); } }
/** * What is the AUC for the current best member of the population. If no member is best, usually * because we haven't done any training yet, then the result is set to NaN. * * @return The AUC of the best member of the population or NaN if we can't figure that out. */ public double auc() { if (best == null) { return Double.NaN; } else { Wrapper payload = best.getPayload(); return payload.getLearner().auc(); } }
/** * What is the AUC for the current best member of the population. If no member is best, usually * because we haven't done any training yet, then the result is set to NaN. * * @return The AUC of the best member of the population or NaN if we can't figure that out. */ public double auc() { if (best == null) { return Double.NaN; } else { Wrapper payload = best.getPayload(); return payload.getLearner().auc(); } }
@Test public void crossFoldLearnerRoundTrip() throws IOException { CrossFoldLearner learner = new CrossFoldLearner(5, 2, 5, new L1()); train(learner, 100); CrossFoldLearner olr3 = roundTrip(learner, CrossFoldLearner.class); double auc1 = learner.auc(); assertTrue(auc1 > 0.85); assertEquals(auc1, learner.auc(), 1.0e-6); assertEquals(auc1, olr3.auc(), 1.0e-6); train(learner, 100); train(learner, 100); train(olr3, 100); assertEquals(learner.auc(), learner.auc(), 0.02); assertEquals(learner.auc(), olr3.auc(), 0.02); double auc2 = learner.auc(); assertTrue(auc2 > auc1); learner.close(); olr3.close(); }
w.train(r); if (i % 1000 == 0) { System.out.printf("%10d %.3f\n", i, w.getLearner().auc()); System.out.printf("%10d %.3f\n", 3000, w.getLearner().auc()); double auc1 = w.getLearner().auc(); if (i % 1000 == 0) { if (i == 0) { assertEquals("Should have started with no data", 0.5, w2.getLearner().auc(), 0.0001); double auc2 = w2.getLearner().auc(); assertTrue("Should have had head-start", Math.abs(auc2 - 0.5) > 0.1); assertTrue("AUC should improve quickly on copy", auc1 < auc2); System.out.printf("%10d %.3f\n", i, w2.getLearner().auc()); assertEquals("Original should not change after copy is updated", auc1, w.getLearner().auc(), 1.0e-5); assertTrue("AUC should improve significantly on copy", auc1 < w2.getLearner().auc() - 0.05); assertEquals(auc1, w.getLearner().auc(), 0);
@Test public void crossValidatedAuc() throws IOException { RandomUtils.useTestSeed(); Random gen = RandomUtils.getRandom(); Matrix data = readCsv("cancer.csv"); CrossFoldLearner lr = new CrossFoldLearner(5, 2, 10, new L1()) .stepOffset(10) .decayExponent(0.7) .lambda(1 * 1.0e-3) .learningRate(5); int k = 0; int[] ordering = permute(gen, data.numRows()); for (int epoch = 0; epoch < 100; epoch++) { for (int row : ordering) { lr.train(row, (int) data.get(row, 9), data.viewRow(row)); System.out.printf("%d,%d,%.3f\n", epoch, k++, lr.auc()); } assertEquals(1, lr.auc(), 0.2); } assertEquals(1, lr.auc(), 0.1); }
/** * The CrossFoldLearner is probably the best learner to use for new applications. * * @throws IOException If test resources aren't readable. */ @Test public void crossValidation() throws IOException { Vector target = readStandardData(); CrossFoldLearner lr = new CrossFoldLearner(5, 2, 8, new L1()) .lambda(1 * 1.0e-3) .learningRate(50); train(getInput(), target, lr); System.out.printf("%.2f %.5f\n", lr.auc(), lr.logLikelihood()); test(getInput(), target, lr, 0.05, 0.3); }