Search in sources :

Example 6 with Frame

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);
}
Also used : Frame(water.fvec.Frame) JsonObject(dontweave.gson.JsonObject)

Example 7 with Frame

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());
            }
        }
    }
}
Also used : Frame(water.fvec.Frame) CreateFrame(hex.CreateFrame) Random(java.util.Random) FrameSplitPage(water.api.FrameSplitPage)

Example 8 with Frame

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);
}
Also used : Frame(water.fvec.Frame) File(java.io.File)

Example 9 with Frame

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;
}
Also used : Frame(water.fvec.Frame) MRTask2(water.MRTask2) Chunk(water.fvec.Chunk) NewChunk(water.fvec.NewChunk) NewChunk(water.fvec.NewChunk)

Example 10 with Frame

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;
}
Also used : Frame(water.fvec.Frame) MRTask2(water.MRTask2) Chunk(water.fvec.Chunk) NewChunk(water.fvec.NewChunk) NewChunk(water.fvec.NewChunk)

Aggregations

Frame (water.fvec.Frame)782 Test (org.junit.Test)435 Vec (water.fvec.Vec)215 ValFrame (water.rapids.vals.ValFrame)132 NFSFileVec (water.fvec.NFSFileVec)66 Val (water.rapids.Val)65 SplitFrame (hex.SplitFrame)59 Key (water.Key)56 DeepLearningParameters (hex.deeplearning.DeepLearningModel.DeepLearningParameters)54 Chunk (water.fvec.Chunk)50 NewChunk (water.fvec.NewChunk)37 MRTask (water.MRTask)33 ShuffleSplitFrame (hex.splitframe.ShuffleSplitFrame)31 Ignore (org.junit.Ignore)28 Random (java.util.Random)26 File (java.io.File)25 BufferedString (water.parser.BufferedString)21 H2OIllegalArgumentException (water.exceptions.H2OIllegalArgumentException)19 HashMap (java.util.HashMap)17 hex (hex)16