@@ -0,0 +1,1717 @@
+package ai.h2o.automl.utils;%0A%0Aimport ai.h2o.automl.transforms.Expr;%0Aimport water.DKV;%0Aimport water.Key;%0Aimport water.MRTask;%0Aimport water.fvec.Chunk;%0Aimport water.fvec.Frame;%0Aimport water.fvec.Vec;%0A%0Aimport java.util.Random;%0A%0A/**%0A * Useful utilities%0A */%0Apublic class AutoMLUtils %7B%0A  public static Vec%5B%5D makeWeights(Vec v, final double trainRatio) %7B%0A    Vec randVec = v.makeZero();%0A    final long seed = water.util.RandomUtils.getRNG(new Random().nextLong()).nextLong();%0A    new MRTask() %7B%0A      @Override public void map(Chunk c)%7B%0A        long start = c.start();%0A        Random rng = new water.util.RandomUtils.PCGRNG(start,1);%0A        for(int i = 0; i %3C c._len; ++i) %7B%0A          rng.setSeed(seed+start+i); // Determinstic per-row%0A          c.set(i, rng.nextFloat() %3C trainRatio ? 1 : 0);%0A        %7D%0A      %7D%0A    %7D.doAll(randVec);%0A    return new Vec%5B%5D%7BrandVec, Expr.binOp(%22-%22, 1, randVec).toWrappedVec().makeVec()%7D;  // gives weight and 1-weight%0A  %7D%0A%0A  public static Frame%5B%5D makeTrainTest(Frame fr, final double trainRatio) %7B%0A    Frame%5B%5D res= new Frame%5B2%5D;%0A    Vec%5B%5D trainTestWeights = makeWeights(fr.anyVec(), 0.8);%0A    Vec%5B%5D vecs = new Vec%5Bfr.numCols()+1%5D;%0A    String%5B%5D names = new String%5Bfr.numCols()+1%5D;%0A    System.arraycopy(fr.names(),0,names,0,fr.names().length);%0A    System.arraycopy(fr.vecs(),0,vecs,0,fr.vecs().length);%0A    names%5Bnames.length-1%5D=%22weight%22;%0A    vecs%5Bvecs.length-1%5D = trainTestWeights%5B0%5D;%0A    res%5B0%5D = new Frame(Key.make(),names.clone(),vecs.clone());  // reclone for safety%0A    DKV.put(res%5B0%5D);%0A    vecs = vecs.clone();%0A    vecs%5Bvecs.length-1%5D = trainTestWeights%5B1%5D;%0A    res%5B1%5D = new Frame(Key.make(), names.clone(),vecs.clone()); // reclone for safety%0A    DKV.put(res%5B1%5D);%0A    return res;%0A  %7D%0A%7D%0A

put train/test weight vec maker into utils