use of water.fvec.Frame in project h2o-2 by h2oai.
the class GroupedAverage method serve.
@Override
public Response serve() {
JsonObject json = new JsonObject();
Frame fr = source.deepSlice(null, null);
UKV.put(destination_key, fr);
return Response.done(json);
}
use of water.fvec.Frame in project h2o-2 by h2oai.
the class LoadDatasets method testTrainSplitFrames.
public void testTrainSplitFrames() {
final Key[] keySet = H2O.KeySnapshot.globalSnapshot().keys();
for (Key key : keySet) {
final Value val = DKV.get(key);
if (val == null || !val.isFrame())
continue;
final Frame fr = val.get();
if (!fr._key.toString().contains("_part")) {
try {
FrameSplitPage fsp = new FrameSplitPage();
fsp.source = fr;
long seed = new Random().nextLong();
Log.info("seed: " + seed);
fsp.ratios = new float[] { 0.001f + new Random(seed).nextFloat() * 0.99f };
Log.info("Splitting frame under key '" + fr._key.toString() + "' into " + fsp.ratios[0] + ".");
fsp.split_keys = new Key[] { Key.make(), Key.make() };
fsp.split_rows = null;
fsp.split_ratios = null;
fsp.invoke();
} catch (Exception ex) {
Log.err(ex.getMessage());
}
}
}
}
use of water.fvec.Frame in project h2o-2 by h2oai.
the class MapReduce method execImpl.
@Override
protected void execImpl() {
// Parse a dataset into a Frame, H2O's distributed table-like data structure
File file = new File(VM.h2oFolder(), "smalldata/iris/iris.csv");
Frame frame = samples.expert.Frames.parse(file);
// Create an instance of our custom map-reduce class.
Sum sum = new Sum();
// Any field set before invoking the task will be copied to other instances created
// for local threads, and serialized to remote instances used on remote nodes.
sum.myInput = "blah";
// Launches a distributed fork-join that will create instances of the task, and run
// them in parallel on each chunk of data for this key. In this example, run on only
// on one column, the second one of the frame.
sum.doAll(frame.vecs()[1]);
// At this point, all task instances have been merged by their 'reduce' method. We
// are back to a state where only one instance exist, and it contains the overall sum.
System.out.println("Sum is " + sum.value);
}
use of water.fvec.Frame in project h2o-2 by h2oai.
the class MRUtils method add.
public static Frame add(Frame fr, final double d) {
Frame r = new MRTask2() {
@Override
public void map(Chunk[] cs, NewChunk[] ncs) {
for (int i = 0; i < ncs.length; i++) {
NewChunk nc = ncs[i];
Chunk c = cs[i];
for (int r = 0; r < c._len; r++) nc.addNum(c.at0(r) + d);
}
}
}.doAll(fr.numCols(), fr).outputFrame(fr.names(), fr.domains());
return r;
}
use of water.fvec.Frame in project h2o-2 by h2oai.
the class MRUtils method pow.
public static Frame pow(Frame fr, final double d) {
Frame r = new MRTask2() {
@Override
public void map(Chunk[] cs, NewChunk[] ncs) {
for (int i = 0; i < ncs.length; i++) {
NewChunk nc = ncs[i];
Chunk c = cs[i];
for (int r = 0; r < c._len; r++) nc.addNum(Math.pow(c.at0(r), d));
}
}
}.doAll(fr.numCols(), fr).outputFrame(fr.names(), fr.domains());
return r;
}
Aggregations