water.fvec.Frame.anyVec()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中water.fvec.Frame.anyVec()方法的一些代码示例,展示了Frame.anyVec()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frame.anyVec()方法的具体详情如下:
包路径:water.fvec.Frame
类名称:Frame
方法名:anyVec

Frame.anyVec介绍

[英]Returns the first readable vector.
[中]返回第一个可读向量。

代码示例

代码示例来源:origin: h2oai/h2o-2

public RebalanceDataSet(Frame modelFrame, Frame srcFrame, Key dstKey, H2O.H2OCountedCompleter cmp, Key jobKey) {
 super(cmp);
 _in = srcFrame;
 _jobKey = jobKey;
 _okey = dstKey;
 _espc = modelFrame.anyVec()._espc;
 _vg = modelFrame.anyVec().group();
}

代码示例来源:origin: h2oai/h2o-2

private int[] howManyRPC(Frame fr) {
 int[] result = new int[fr.anyVec().nChunks()];
 for(int i = 0; i < result.length; ++i) {
  result[i] = fr.anyVec().chunkLen(i);
 }
 return result;
}

代码示例来源:origin: h2oai/h2o-2

/** Return chunk index of the first chunk on this node. Used to identify the trees built here.*/
private long getChunkId(final Frame fr) {
 Key[] keys = new Key[fr.anyVec().nChunks()];
 for(int i = 0; i < fr.anyVec().nChunks(); ++i) {
  keys[i] = fr.anyVec().chunkKey(i);
 }
 for(int i = 0; i < keys.length; ++i) {
  if (keys[i].home()) return i;
 }
 return -99999; //throw new Error("No key on this node");
}

代码示例来源:origin: h2oai/h2o-2

@Override protected void init() throws IllegalArgumentException {
 // Input handling
 if( actual==null || predict==null )
  throw new IllegalArgumentException("Missing actual or predict!");
 if( vactual==null )
  throw new IllegalArgumentException("Missing vactual!");
 if (vactual.length() != predict.anyVec().length())
  throw new IllegalArgumentException("Both arguments must have the same length!");
 if (!vactual.isInt())
  throw new IllegalArgumentException("Actual column must be integer class labels!");
}

代码示例来源:origin: h2oai/h2o-3

/**
 * @param frame
 * @param name name of the fold column
 * @param nfolds number of folds
 * @param seed
 */
static public Frame addKFoldColumn(Frame frame, String name, int nfolds, long seed) {
 Vec foldVec = frame.anyVec().makeZero();
 frame.add(name, AstKFold.kfoldColumn(foldVec, nfolds, seed == -1 ? new Random().nextLong() : seed));
 return frame;
}

代码示例来源:origin: h2oai/h2o-2

private int producerRemoteRows(byte treeProducerID, Key chunkKey) {
 Key[] remoteCKeys = _remoteChunksKeys[treeProducerID];
 int off = 0;
 for (int i=0; i<remoteCKeys.length; i++) {
  if (chunkKey.equals(remoteCKeys[i])) return off;
  off += _data.anyVec().chunkLen(i);
 }
 return off;
}

代码示例来源:origin: h2oai/h2o-3

@Override
protected Frame makeValidWorkspace() {
 // FIXME: this is not efficient, we need a sparse volatile chunks
 Vec[] tmp = _valid.anyVec().makeVolatileDoubles(numClassTrees());
 String[] tmpNames = new String[tmp.length];
 for (int i = 0; i < tmpNames.length; i++)
  tmpNames[i] = "__P_" + i;
 return new Frame(tmpNames, tmp);
}

代码示例来源:origin: h2oai/h2o-2

void pop( Env global ) {
 assert _sp > _display[_tod]; // Do not over-pop current scope
 _sp--;
 _fcn[_sp]=global.subRef(_fcn[_sp]);
 _ary[_sp]=global.subRef(_ary[_sp],_key[_sp]);
 assert _sp==0 || _ary[0]==null || check_refcnt(_ary[0].anyVec());
}
public void popUncheck( ) {

代码示例来源:origin: h2oai/h2o-2

@Override
public void compute2() {
 _z = new Frame(_x.anyVec().makeZeros(_y.numCols()));
 int total_cores = H2O.CLOUD.size()*H2O.NUMCPUS;
 int chunksPerCol = _y.anyVec().nChunks();
 int maxP = 256*total_cores/chunksPerCol;
 Log.info("maxP = " + maxP);
 _cntr = new AtomicInteger(maxP-1);
 addToPendingCount(2*_y.numCols()-1);
 for(int i = 0; i < Math.min(_y.numCols(),maxP); ++i)
  forkVecTask(i);
}

代码示例来源:origin: h2oai/h2o-3

static Vec makeStrataVec(Frame f, String[] stratifyBy, IcedHashMap<AstGroup.G, IcedInt> mapping) {
 final Frame sf = f.subframe(stratifyBy);
 return new StrataTask(mapping).doAll(Vec.T_NUM, sf).outputFrame().anyVec();
}

代码示例来源:origin: h2oai/h2o-2

@Override void apply(Env env, int argcnt, ASTApply apply) {
  String skey = env.key();
  Frame fr = env.popAry();
  if (fr.numCols() != 1) throw new IllegalArgumentException("trim works on a single column at a time.");
  String[] doms = fr.anyVec().domain().clone();
  for (int i = 0; i < doms.length; ++i) doms[i] = doms[i].trim();
  Frame fr2 = new Frame(fr.names(), fr.vecs());
  fr2.anyVec()._domain = doms;
  env.subRef(fr, skey);
  env.poppush(1, fr2, null);
 }
}

代码示例来源:origin: h2oai/h2o-2

void push_slot( int d, int n ) {
 assert d==0;                // Should use a fcn's closure for d>1
 int idx = _display[_tod-d]+n;
 push(1);
 _ary[_sp-1] = addRef(_ary[idx]);
 _d  [_sp-1] =        _d  [idx];
 _fcn[_sp-1] = addRef(_fcn[idx]);
 _str[_sp-1] =        _str[idx];
 assert _ary[0]==null || check_refcnt(_ary[0].anyVec());
}
void push_slot( int d, int n, Env global ) {

代码示例来源:origin: h2oai/h2o-2

void push_slot( int d, int n, Env global ) {
 assert _refcnt==null;       // Should use a fcn's closure for d>1
 int idx = _display[_tod-d]+n;
 int gidx = global._sp;
 global.push(1);
 global._ary[gidx] = global.addRef(_ary[idx]);
 global._d  [gidx] =               _d  [idx] ;
 global._fcn[gidx] = global.addRef(_fcn[idx]);
 global._str[gidx] =               _str[idx] ;
 assert _ary[0]==null || global.check_refcnt(_ary[0].anyVec());
}
// Copy from TOS into a slot.  Does NOT pop results.

代码示例来源:origin: h2oai/h2o-2

@Override public boolean toHTML( StringBuilder sb ) {
 if (UKV.get(after)==null) {
  return false;
 }
 RString aft = new RString("<a href='Inspect2.html?src_key=%$key'>%key</a>");
 aft.replace("key", after);
 DocGen.HTML.section(sb, "Rebalancing done. Frame '" + aft.toString()
     + "' now has " + ((Frame)UKV.get(after)).anyVec().nChunks()
     + " chunks (source: " + source.anyVec().nChunks() + ").");
 return true;
}

代码示例来源:origin: h2oai/h2o-3

@Override public long progressUnits() {
 return isPreTrained() ? _pre_trained.get().anyVec().nChunks() : train().vec(0).nChunks() * _epochs;
}
static final int MAX_VEC_SIZE = 10000;

代码示例来源:origin: h2oai/h2o-2

void tos_into_slot( int idx, String id ) {
 subRef(_ary[idx], _key[idx]);
 subRef(_fcn[idx]);
 Frame fr =                   _ary[_sp-1];
 _ary[idx] = fr==null ? null : addRef(new Frame(fr));
 _d  [idx] =                  _d  [_sp-1] ;
 _fcn[idx] =           addRef(_fcn[_sp-1]);
 _str[idx] =                  _str[_sp-1] ;
 _key[idx] = fr!=null ? id : null;
 assert _ary[0]== null || check_refcnt(_ary[0].anyVec());
}

代码示例来源:origin: h2oai/h2o-2

@Override protected Boolean defaultValue() {
  // Can we allocate ALL of the dataset locally?
  long bs = fr().byteSize();
  if( !MemoryManager.tryReserveTaskMem(bs) ) return false;
  // Also, do we have enough chunks to run it well globally?
  if( fr().anyVec().nChunks() >= 2*H2O.CLOUD.size() ) return false;
  // Less than 2 chunks per node, and fits locally... default to local-only
  return true;
 }
}

代码示例来源:origin: h2oai/h2o-2

public final void exec( int outputs, Frame fr, boolean run_local){
 // Use first readable vector to gate home/not-home
 fr.checkCompatible();       // Check for compatible vectors
 if((_noutputs = outputs) > 0) _vid = fr.anyVec().group().reserveKeys(outputs);
 _fr = fr;                   // Record vectors to work on
 _nxx = (short)H2O.SELF.index(); _nhi = (short)H2O.CLOUD.size(); // Do Whole Cloud
 _run_local = run_local;     // Run locally by copying data, or run globally?
 setupLocal0();              // Local setup
 compute2();
}

代码示例来源:origin: h2oai/h2o-2

private void testOneLineDataset(String filename, String keyname) {
 Key fkey = load_test_file(filename);
 Key okey = Key.make(keyname);
 Frame fr = ParseDataset2.parse(okey,new Key[]{fkey});
 assertEquals(filename + ": number of chunks == 1", 1, fr.anyVec().nChunks());
 assertEquals(filename + ": number of rows   == 2", 2, fr.numRows());
 assertEquals(filename + ": number of cols   == 9", 9, fr.numCols());
 fr.delete();
}

代码示例来源:origin: h2oai/h2o-3

private static Frame selectByPredicate(Frame fr, Frame predicateFrame) {
 String[] names = fr.names().clone();
 byte[] types = fr.types().clone();
 String[][] domains = fr.domains().clone();
 fr.add("predicate", predicateFrame.anyVec());
 Frame filtered = new Frame.DeepSelect().doAll(types, fr).outputFrame(Key.<Frame>make(), names, domains);
 predicateFrame.delete();
 fr.remove("predicate");
 return filtered;
}

相关文章