Search in sources :

Example 1 with LogLoss

use of com.alibaba.alink.operator.common.tree.parallelcart.loss.LogLoss in project Alink by alibaba.

the class BoostingTest method testGradient.

@Test
public void testGradient() {
    GradientBaseBooster booster = new GradientBaseBooster(new LogLoss(2.0, 1.0), new double[] { 1.0, 1.0, 1.0 }, new Slice(0, 3));
    booster.boosting(null, new double[] { 1, 1, 0 }, new double[] { 0.5, 0.5, 0.1 });
    Assert.assertArrayEquals(new double[] { 0.3775406687981454, 0.3775406687981454, -0.52497918747894 }, booster.getGradients(), 1e-6);
    Assert.assertArrayEquals(new double[] { 0.1425369565965509, 0.1425369565965509, 0.27560314728604807 }, booster.getGradientsSqr(), 1e-6);
    Assert.assertNull(booster.getHessions());
    Assert.assertArrayEquals(new double[] { 1.0, 1.0, 1.0 }, booster.getWeights(), 1e-6);
}
Also used : LogLoss(com.alibaba.alink.operator.common.tree.parallelcart.loss.LogLoss) Slice(com.alibaba.alink.operator.common.tree.parallelcart.data.Slice) GradientBaseBooster(com.alibaba.alink.operator.common.tree.parallelcart.booster.GradientBaseBooster) Test(org.junit.Test)

Aggregations

GradientBaseBooster (com.alibaba.alink.operator.common.tree.parallelcart.booster.GradientBaseBooster)1 Slice (com.alibaba.alink.operator.common.tree.parallelcart.data.Slice)1 LogLoss (com.alibaba.alink.operator.common.tree.parallelcart.loss.LogLoss)1 Test (org.junit.Test)1