}
@Test
public void onlineAucRoundtrip() {
RandomUtils.useTestSeed();
OnlineAuc auc1 = new GlobalOnlineAuc();
Random gen = RandomUtils.getRandom();
for (int i = 0; i < 10000; i++) {
auc1.addSample(0, gen.nextGaussian());
auc1.addSample(1, gen.nextGaussian() + 1);
}
assertEquals(0.76, auc1.auc(), 0.01);
Gson gson = ModelSerializer.gson();
String s = gson.toJson(auc1);
OnlineAuc auc2 = gson.fromJson(s, GlobalOnlineAuc.class);
assertEquals(auc1.auc(), auc2.auc(), 0);
for (int i = 0; i < 1000; i++) {
auc1.addSample(0, gen.nextGaussian());
auc1.addSample(1, gen.nextGaussian() + 1);
auc2.addSample(0, gen.nextGaussian());
auc2.addSample(1, gen.nextGaussian() + 1);
}
assertEquals(auc1.auc(), auc2.auc(), 0.01);
Foo x = new Foo();
x.foo = auc1;
x.pig = 3.13;
x.dog = 42;