@Test public void stepSize() { assertEquals(500, AdaptiveLogisticRegression.stepSize(15000, 2)); assertEquals(2000, AdaptiveLogisticRegression.stepSize(15000, 2.6)); assertEquals(5000, AdaptiveLogisticRegression.stepSize(24000, 2.6)); assertEquals(10000, AdaptiveLogisticRegression.stepSize(15000, 3)); }
AdaptiveLogisticRegression.TrainingExample r = getExample(i, gen, beta); w.train(r); if (i % 1000 == 0) { if (i % 1000 == 0) { if (i == 0) { assertEquals("Should have started with no data", 0.5, w2.getLearner().auc(), 0.0001); assertTrue("Should have had head-start", Math.abs(auc2 - 0.5) > 0.1); assertTrue("AUC should improve quickly on copy", auc1 < auc2); AdaptiveLogisticRegression.TrainingExample r = getExample(i, gen, beta); w2.train(r); 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);
AdaptiveLogisticRegression.TrainingExample r = getExample(i, gen, beta); cl.train(r); if (i % 1000 == 0) { assertEquals(1, cl.getLearner().auc(), 0.1); AdaptiveLogisticRegression.TrainingExample r = getExample(i, gen, beta); adaptiveLogisticRegression.train(r.getKey(), r.getActual(), r.getInstance()); if (i % 1000 == 0 && adaptiveLogisticRegression.getBest() != null) { assertEquals(1, adaptiveLogisticRegression.auc(), 0.1); adaptiveLogisticRegression.close();
@Test @ThreadLeakLingering(linger = 1000) public void constantStep() { AdaptiveLogisticRegression lr = new AdaptiveLogisticRegression(2, 1000, new L1()); lr.setInterval(5000); assertEquals(20000, lr.nextStep(15000)); assertEquals(20000, lr.nextStep(15001)); assertEquals(20000, lr.nextStep(16500)); assertEquals(20000, lr.nextStep(19999)); lr.close(); }
@Test @ThreadLeakLingering(linger = 1000) public void growingStep() { AdaptiveLogisticRegression lr = new AdaptiveLogisticRegression(2, 1000, new L1()); lr.setInterval(2000, 10000); // start with minimum step size for (int i = 2000; i < 20000; i+=2000) { assertEquals(i + 2000, lr.nextStep(i)); } // then level up a bit for (int i = 20000; i < 50000; i += 5000) { assertEquals(i + 5000, lr.nextStep(i)); } // and more, but we top out with this step size for (int i = 50000; i < 500000; i += 10000) { assertEquals(i + 10000, lr.nextStep(i)); } lr.close(); } }