StringReader smallReader = new StringReader(smallValues);
EventStream smallEventStream = new RealBasicEventStream(
new PlainTextByLineDataStream(smallReader));
MaxentModel smallModel = GIS.trainModel(100,
new OnePassRealValueDataIndexer(smallEventStream, 0), false);
String[] contexts = smallTest.split(" ");
float[] values = RealValueFileEventStream.parseContexts(contexts);
double[] smallResults = smallModel.eval(contexts, values);
String smallResultString = smallModel.getAllOutcomes(smallResults);
System.out.println("smallResults: " + smallResultString);
StringReader largeReader = new StringReader(largeValues);
EventStream largeEventStream = new RealBasicEventStream(
new PlainTextByLineDataStream(largeReader));
MaxentModel largeModel = GIS.trainModel(100,
new OnePassRealValueDataIndexer(largeEventStream, 0), false);
contexts = largeTest.split(" ");
values = RealValueFileEventStream.parseContexts(contexts);
double[] largeResults = largeModel.eval(contexts, values);
String largeResultString = smallModel.getAllOutcomes(largeResults);
System.out.println("largeResults: " + largeResultString);
assertEquals(smallResults.length, largeResults.length);
for (int i = 0; i < smallResults.length; i++) {
System.out.println(String.format(
"classifiy with smallModel: %1$s = %2$f", smallModel.getOutcome(i),
smallResults[i]));
System.out.println(String.format(
"classifiy with largeModel: %1$s = %2$f", largeModel.getOutcome(i),
largeResults[i]));
assertEquals(smallResults[i], largeResults[i], 0.01f);
}
}