Search in sources :

Example 6 with AggregatorModel

use of hex.aggregator.AggregatorModel in project h2o-3 by h2oai.

the class AggregatorTest method testChunks.

@Test
public void testChunks() {
    Frame frame = parse_test_file("smalldata/covtype/covtype.20k.data");
    AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
    parms._train = frame._key;
    parms._target_num_exemplars = 137;
    parms._rel_tol_num_exemplars = 0.05;
    long start = System.currentTimeMillis();
    // 0.418
    AggregatorModel agg = new Aggregator(parms).trainModel().get();
    System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start) / 1000. + " seconds");
    agg.checkConsistency();
    Frame output = agg._output._output_frame.get();
    checkNumExemplars(agg);
    output.remove();
    agg.remove();
    for (int i : new int[] { 1, 2, 5, 10, 50, 100 }) {
        Key key = Key.make();
        RebalanceDataSet rb = new RebalanceDataSet(frame, key, i);
        H2O.submitTask(rb);
        rb.join();
        Frame rebalanced = DKV.get(key).get();
        parms = new AggregatorModel.AggregatorParameters();
        parms._train = frame._key;
        parms._target_num_exemplars = 137;
        parms._rel_tol_num_exemplars = 0.05;
        start = System.currentTimeMillis();
        // 0.373 0.504 0.357 0.454 0.368 0.355
        AggregatorModel agg2 = new Aggregator(parms).trainModel().get();
        System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start) / 1000. + " seconds");
        agg2.checkConsistency();
        Log.info("Number of exemplars for " + i + " chunks: " + agg2._exemplars.length);
        rebalanced.delete();
        Assert.assertTrue(Math.abs(agg._exemplars.length - agg2._exemplars.length) == 0);
        output = agg2._output._output_frame.get();
        output.remove();
        checkNumExemplars(agg);
        agg2.remove();
    }
    frame.delete();
}
Also used : CreateFrame(hex.CreateFrame) Frame(water.fvec.Frame) RebalanceDataSet(water.fvec.RebalanceDataSet) Aggregator(hex.aggregator.Aggregator) AggregatorModel(hex.aggregator.AggregatorModel) Test(org.junit.Test)

Example 7 with AggregatorModel

use of hex.aggregator.AggregatorModel in project h2o-3 by h2oai.

the class AggregatorTest method testAggregator.

public void testAggregator(int max) {
    CreateFrame cf = new CreateFrame();
    cf.rows = 100000;
    cf.cols = 2;
    cf.categorical_fraction = 0.1;
    cf.integer_fraction = 0.3;
    cf.real_range = 100;
    cf.integer_range = 100;
    cf.seed = 1234;
    Frame frame = cf.execImpl().get();
    AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
    parms._train = frame._key;
    parms._target_num_exemplars = max;
    long start = System.currentTimeMillis();
    AggregatorModel agg = new Aggregator(parms).trainModel().get();
    System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start) / 1000. + " seconds");
    agg.checkConsistency();
    Frame output = agg._output._output_frame.get();
    System.out.println(output.toTwoDimTable(0, 10));
    frame.delete();
    checkNumExemplars(agg);
    output.remove();
    agg.remove();
}
Also used : CreateFrame(hex.CreateFrame) Frame(water.fvec.Frame) Aggregator(hex.aggregator.Aggregator) CreateFrame(hex.CreateFrame) AggregatorModel(hex.aggregator.AggregatorModel)

Example 8 with AggregatorModel

use of hex.aggregator.AggregatorModel in project h2o-3 by h2oai.

the class AggregatorTest method testCovtype.

@Test
public void testCovtype() {
    Frame frame = parse_test_file("smalldata/covtype/covtype.20k.data");
    AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
    parms._train = frame._key;
    parms._target_num_exemplars = 500;
    parms._rel_tol_num_exemplars = 0.05;
    long start = System.currentTimeMillis();
    // 0.179
    AggregatorModel agg = new Aggregator(parms).trainModel().get();
    System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start) / 1000. + " seconds");
    agg.checkConsistency();
    frame.delete();
    Frame output = agg._output._output_frame.get();
    Log.info("Exemplars: " + output.toString());
    output.remove();
    checkNumExemplars(agg);
    agg.remove();
}
Also used : CreateFrame(hex.CreateFrame) Frame(water.fvec.Frame) Aggregator(hex.aggregator.Aggregator) AggregatorModel(hex.aggregator.AggregatorModel) Test(org.junit.Test)

Example 9 with AggregatorModel

use of hex.aggregator.AggregatorModel in project h2o-3 by h2oai.

the class AggregatorTest method testAggregatorEigen.

@Test
public void testAggregatorEigen() {
    CreateFrame cf = new CreateFrame();
    cf.rows = 1000;
    cf.cols = 10;
    cf.categorical_fraction = 0.6;
    cf.integer_fraction = 0.0;
    cf.binary_fraction = 0.0;
    cf.real_range = 100;
    cf.integer_range = 100;
    cf.missing_fraction = 0;
    cf.factors = 5;
    cf.seed = 1234;
    Frame frame = cf.execImpl().get();
    AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
    parms._train = frame._key;
    parms._categorical_encoding = Model.Parameters.CategoricalEncodingScheme.Eigen;
    long start = System.currentTimeMillis();
    // 0.905
    AggregatorModel agg = new Aggregator(parms).trainModel().get();
    System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start) / 1000. + " seconds");
    agg.checkConsistency();
    Frame output = agg._output._output_frame.get();
    System.out.println(output.toTwoDimTable(0, 10));
    Log.info("Number of exemplars: " + agg._exemplars.length);
    output.remove();
    frame.remove();
    agg.remove();
}
Also used : CreateFrame(hex.CreateFrame) Frame(water.fvec.Frame) Aggregator(hex.aggregator.Aggregator) CreateFrame(hex.CreateFrame) AggregatorModel(hex.aggregator.AggregatorModel) Test(org.junit.Test)

Example 10 with AggregatorModel

use of hex.aggregator.AggregatorModel in project h2o-3 by h2oai.

the class AggregatorTest method testMNIST.

@Ignore
@Test
public void testMNIST() {
    Frame frame = parse_test_file("bigdata/laptop/mnist/train.csv.gz");
    AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
    parms._train = frame._key;
    long start = System.currentTimeMillis();
    AggregatorModel agg = new Aggregator(parms).trainModel().get();
    System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start) / 1000. + " seconds");
    agg.checkConsistency();
    frame.delete();
    Frame output = agg._output._output_frame.get();
    //    Log.info("Exemplars: " + output);
    output.remove();
    Log.info("Number of exemplars: " + agg._exemplars.length);
    checkNumExemplars(agg);
    agg.remove();
}
Also used : CreateFrame(hex.CreateFrame) Frame(water.fvec.Frame) Aggregator(hex.aggregator.Aggregator) AggregatorModel(hex.aggregator.AggregatorModel) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CreateFrame (hex.CreateFrame)10 Aggregator (hex.aggregator.Aggregator)10 AggregatorModel (hex.aggregator.AggregatorModel)10 Frame (water.fvec.Frame)10 Test (org.junit.Test)9 Ignore (org.junit.Ignore)3 RebalanceDataSet (water.fvec.RebalanceDataSet)1 Vec (water.fvec.Vec)1