use of hex.aggregator.Aggregator in project h2o-3 by h2oai.
the class AggregatorTest method testCovtypeMemberIndices.
@Ignore
@Test
public void testCovtypeMemberIndices() {
Frame frame = parse_test_file("smalldata/covtype/covtype.20k.data");
AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
parms._train = frame._key;
parms._target_num_exemplars = 117;
long start = System.currentTimeMillis();
// 1.489
AggregatorModel agg = new Aggregator(parms).trainModel().get();
System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start) / 1000. + " seconds");
agg.checkConsistency();
// Frame assignment = new Frame(new Vec[]{(Vec)agg._exemplar_assignment_vec_key.get()});
// Frame.export(assignment, "/tmp/assignment", "yada", true);
// Log.info("Exemplars: " + new Frame(new Vec[]{(Vec)agg._exemplar_assignment_vec_key.get()}).toString(0,20000));
Log.info("Number of exemplars: " + agg._exemplars.length);
Key<Frame> memberKey = Key.make();
for (int i = 0; i < agg._exemplars.length; ++i) {
Frame members = agg.scoreExemplarMembers(memberKey, i);
assert (members.numRows() == agg._counts[i]);
// Log.info(members);
members.delete();
}
Frame output = agg._output._output_frame.get();
output.remove();
checkNumExemplars(agg);
frame.delete();
agg.remove();
}
use of hex.aggregator.Aggregator in project h2o-3 by h2oai.
the class AggregatorTest method testAggregatorOneHot.
@Test
public void testAggregatorOneHot() {
Scope.enter();
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.1;
cf.factors = 5;
cf.seed = 1234;
Frame frame = cf.execImpl().get();
AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
parms._train = frame._key;
parms._target_num_exemplars = 278;
parms._transform = DataInfo.TransformType.NORMALIZE;
parms._categorical_encoding = Model.Parameters.CategoricalEncodingScheme.OneHotExplicit;
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));
checkNumExemplars(agg);
output.remove();
frame.remove();
agg.remove();
Scope.exit();
}
use of hex.aggregator.Aggregator in project h2o-3 by h2oai.
the class AggregatorTest method testDomains.
@Test
public void testDomains() {
Frame frame = parse_test_file("smalldata/junit/weather.csv");
for (String s : new String[] { "MaxWindSpeed", "RelHumid9am", "Cloud9am" }) {
Vec v = frame.vec(s);
Vec newV = v.toCategoricalVec();
frame.remove(s);
frame.add(s, newV);
v.remove();
}
DKV.put(frame);
AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
parms._train = frame._key;
parms._target_num_exemplars = 17;
AggregatorModel agg = new Aggregator(parms).trainModel().get();
Frame output = agg._output._output_frame.get();
Assert.assertTrue(output.numRows() <= 17);
boolean same = true;
for (int i = 0; i < frame.numCols(); ++i) {
if (frame.vec(i).isCategorical()) {
same = (frame.domains()[i].length == output.domains()[i].length);
if (!same)
break;
}
}
frame.remove();
output.remove();
agg.remove();
Assert.assertFalse(same);
}
use of hex.aggregator.Aggregator in project h2o-3 by h2oai.
the class AggregatorTest method testAggregatorBinary.
@Test
public void testAggregatorBinary() {
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.1;
cf.factors = 5;
cf.seed = 1234;
Frame frame = cf.execImpl().get();
AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
parms._train = frame._key;
parms._transform = DataInfo.TransformType.NORMALIZE;
parms._categorical_encoding = Model.Parameters.CategoricalEncodingScheme.Binary;
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);
Assert.assertTrue(agg._exemplars.length == 1000);
output.remove();
frame.remove();
agg.remove();
}
use of hex.aggregator.Aggregator in project h2o-3 by h2oai.
the class AggregatorTest method testAirlines.
@Ignore
@Test
public void testAirlines() {
Frame frame = parse_test_file("smalldata/airlines/allyears2k_headers.zip");
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();
output.remove();
checkNumExemplars(agg);
agg.remove();
}
Aggregations