Search in sources :

Example 1 with VarianceSplitCalculator

use of org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.VarianceSplitCalculator in project ignite by apache.

the class VarianceSplitCalculatorTest method testSplitTwoClassesTwoPoints.

/**
 * Test calculation of split of region consisting from two classes.
 */
@Test
public void testSplitTwoClassesTwoPoints() {
    double[] labels = new double[] { 0.0, 1.0 };
    double[] values = new double[] { 0.0, 1.0 };
    Integer[] samples = new Integer[] { 0, 1 };
    VarianceSplitCalculator.VarianceData data = new VarianceSplitCalculator.VarianceData(0.25, 2, 0.5);
    SplitInfo<VarianceSplitCalculator.VarianceData> split = new VarianceSplitCalculator().splitRegion(samples, values, labels, 0, data);
    assert split.leftData().impurity() == 0;
    assert split.leftData().mean() == 0;
    assert split.leftData().getSize() == 1;
    assert split.rightData().impurity() == 0;
    assert split.rightData().mean() == 1;
    assert split.rightData().getSize() == 1;
}
Also used : VarianceSplitCalculator(org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.VarianceSplitCalculator) Test(org.junit.Test)

Aggregations

VarianceSplitCalculator (org.apache.ignite.ml.trees.trainers.columnbased.contsplitcalcs.VarianceSplitCalculator)1 Test (org.junit.Test)1