@Test public void testValueAtNonInitialPoint01() throws IOException { // given RealValueFileEventStream rvfes1 = new RealValueFileEventStream( "src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt", "UTF-8"); testDataIndexer.index(rvfes1); NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer); // when double[] nonInitialPoint = new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; double value = objectFunction.valueAt(nonInitialPoint); double expectedValue = 13.862943611198894; // then Assert.assertEquals(expectedValue, value, TOLERANCE01); }
@Test public void testValueAtInitialPoint() throws IOException { // given RealValueFileEventStream rvfes1 = new RealValueFileEventStream( "src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt", "UTF-8"); testDataIndexer.index(rvfes1); NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer); // when double value = objectFunction.valueAt(objectFunction.getInitialPoint()); double expectedValue = 13.86294361; // then Assert.assertEquals(expectedValue, value, TOLERANCE01); }
@Test public void testValueAtNonInitialPoint02() throws IOException { // given RealValueFileEventStream rvfes1 = new RealValueFileEventStream( "src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt", "UTF-8"); testDataIndexer.index(rvfes1); NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer); // when double[] nonInitialPoint = new double[] { 3, 2, 3, 2, 3, 2, 3, 2, 3, 2 }; double value = objectFunction.valueAt(dealignDoubleArrayForTestData(nonInitialPoint, testDataIndexer.getPredLabels(), testDataIndexer.getOutcomeLabels())); double expectedValue = 53.163219721099026; // then Assert.assertEquals(expectedValue, value, TOLERANCE02); }