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

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

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

Frame.add介绍

[英]Appends a named column, keeping the last Vec as the response
[中]追加一个命名列,保留最后一个Vec作为响应

代码示例

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

public void addResponse(String [] names, Vec[] vecs) {
 _adaptedFrame.add(names,vecs);
 _responses += vecs.length;
}

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

public Frame add( Frame fr, boolean rename ) {
 if( !rename ) return add(fr,fr._names);
 String names[] = new String[fr._names.length];
 for( int i=0; i<names.length; i++ ) {
  String name = fr._names[i];
  int cnt=0;
  while( find(name) != -1 )
   name = fr._names[i]+"_"+(cnt++);
  names[i] = name;
 }
 return add(fr,names);
}

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

static Frame discretizeTime(double[] time, Vec startVec, Vec stopVec) {
 final boolean hasStartColumn = startVec != null;
 final Frame f = new Frame();
 if (hasStartColumn)
  f.add("__startCol", startVec);
 f.add("__stopCol", stopVec);
 return new DiscretizeTimeTask(time, startVec != null).doAll(hasStartColumn ? 2 : 1, Vec.T_NUM, f).outputFrame();
}

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

private static Frame fullFrame(CoxPH coxPH, Frame adaptFr, Frame train) {
 if (! coxPH._parms.isStratified())
  return adaptFr;
 Frame ff = new Frame();
 for (String col : coxPH._parms._stratify_by)
  if (adaptFr.vec(col) == null)
   ff.add(col, train.vec(col));
 ff.add(adaptFr);
 return ff;
}

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

@Override
 public Frame makeInteractions(Frame f) {
  Model.InteractionPair[] interactions = _interactionSpec.makeInteractionPairs(f);
  f.add(Model.makeInteractions(f, false, interactions, data_info._useAllFactorLevels, data_info._skipMissing, data_info._predictor_transform == DataInfo.TransformType.STANDARDIZE));
  return f;
 }
}

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

@Override
 public Frame makeInteractions(Frame f) {
  InteractionPair[] interactionPairs = _dinfo._interactionSpec.makeInteractionPairs(f);
  f.add(Model.makeInteractions(f, false, interactionPairs, true, true, false));
  return f;
 }
}

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

static Frame stratifyTime(Frame f, double[] time, String[] stratifyBy, IcedHashMap<AstGroup.G, IcedInt> mapping,
             Vec startVec, Vec stopVec) {
 final Frame sf = f.subframe(stratifyBy);
 final boolean hasStartColumn = startVec != null;
 if (hasStartColumn)
  sf.add("__startVec", startVec);
 sf.add("__stopVec", stopVec);
 return new StrataTask(mapping, time, hasStartColumn).doAll(hasStartColumn ? 3 : 2, Vec.T_NUM, sf).outputFrame();
}

代码示例来源: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-3

ModelMetrics scoreAndMakeModelMetrics(SharedTreeModel model, Frame fr, Frame adaptedFr, boolean buildTreeOneNode) {
 Frame input = _preds != null ? new Frame(adaptedFr).add(_preds) : adaptedFr;
 return doAll(input, buildTreeOneNode)
     .makeModelMetrics(model, fr, adaptedFr, _preds);
}

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

@Override
 public Frame makeInteractions(Frame f) {
  Model.InteractionPair[] interactionPairs = dataInfo._interactionSpec.makeInteractionPairs(f);
  f.add(Model.makeInteractions(f, false, interactionPairs, true, true, false));
  return f;
 }
};

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

public DataInfo validDinfo(Frame valid) {
 DataInfo res = new DataInfo(_adaptedFrame,null,1,_useAllFactorLevels,TransformType.NONE,TransformType.NONE,_skipMissing,_imputeMissing,!(_skipMissing || _imputeMissing),_weights,_offset,_fold);
 res._interactions = _interactions;
 res._interactionSpec = _interactionSpec;
 if (_interactionSpec != null) {
  valid = Model.makeInteractions(valid, true, _interactions, _useAllFactorLevels, _skipMissing, false).add(valid);
 }
 res._adaptedFrame = new Frame(_adaptedFrame.names(),valid.vecs(_adaptedFrame.names()));
 res._valid = true;
 return res;
}

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

@Override
 int prep(Frame fr) {
  String[] names = fr.names().clone();
  Vec[] en = fr.remove(new int[]{1,4,5,8});
  fr.add(names[1], VecUtils.toCategoricalVec(en[0])); //CAPSULE
  fr.add(names[4], VecUtils.toCategoricalVec(en[1])); //DPROS
  fr.add(names[5], VecUtils.toCategoricalVec(en[2])); //DCAPS
  fr.add(names[8], VecUtils.toCategoricalVec(en[3])); //GLEASON
  for (Vec v : en) v.remove();
  fr.remove(0).remove(); //drop ID
  return 4; //CAPSULE
 }
},

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

Frame addNoise(Frame fr, String applyToColumnName, double noiseLevel, long seed) {
 int appyToColumnIndex = fr.find(applyToColumnName);
 if (seed == -1) seed = new Random().nextLong();
 Vec zeroVec = Vec.makeZero(fr.numRows());
 Vec randomVec = zeroVec.makeRand(seed);
 Vec runif = fr.add("runif", randomVec);
 int runifIdx = fr.find("runif");
 new AddNoiseTask(appyToColumnIndex, runifIdx, noiseLevel).doAll(fr);
 fr.remove("runif");
 randomVec.remove();
 zeroVec.remove();
 runif.remove();
 return fr;
}

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

static Vec unifyFrame(DRF drf, Frame fr, PrepData prep) {
 int idx = prep.prep(fr);
 if( idx < 0 ) { drf.classification = false; idx = ~idx; }
 String rname = fr._names[idx];
 drf.response = fr.vecs()[idx];
 fr.remove(idx);           // Move response to the end
 fr.add(rname,drf.response);
 return drf.response;
}

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

Frame calculateAndAppendTEEncoding(Frame fr, Frame encodingMap, String targetColumnName, String appendedColumnName) {
 int numeratorIndex = fr.find("numerator");
 int denominatorIndex = fr.find("denominator");
 double globalMeanForTargetClass = calculatePriorMean(encodingMap); // we can only operate on encodingsMap because `fr` could not have target column at all
 Vec zeroVec = Vec.makeZero(fr.numRows());
 fr.add(appendedColumnName, zeroVec);
 int encodingsColumnIdx = fr.find(appendedColumnName);
 new CalcEncodings(numeratorIndex, denominatorIndex, globalMeanForTargetClass, encodingsColumnIdx).doAll( fr);
 zeroVec.remove();
 return fr;
}

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

@Override
 int prep(Frame fr) {
  Vec resp = fr.remove("C2");
  fr.add("C2", resp.toCategoricalVec());
  resp.remove();
  return fr.find("C3");
 }
},

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

@Override
 int prep(Frame fr) {
  Vec resp = fr.remove("C2");
  fr.add("C2", VecUtils.toCategoricalVec(resp));
  resp.remove();
  return fr.find("C3");
 }
},

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

Frame calculateAndAppendBlendedTEEncoding(Frame fr, Frame encodingMap, String targetColumnName, String appendedColumnName) {
 int numeratorIndex = fr.find("numerator");
 int denominatorIndex = fr.find("denominator");
 double globalMeanForTargetClass = calculatePriorMean(encodingMap); // TODO since target column is the same for all categorical columns we are trying to encode we can compute global mean only once.
 Log.info("Global mean for blending = " + globalMeanForTargetClass);
 Vec zeroVec = Vec.makeZero(fr.numRows());
 fr.add(appendedColumnName, zeroVec);
 int encodingsColumnIdx = fr.find(appendedColumnName);
 new CalcEncodingsWithBlending(numeratorIndex, denominatorIndex, globalMeanForTargetClass, _blendingParams, encodingsColumnIdx).doAll(fr);
 zeroVec.remove();
 return fr;
}

代码示例来源: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;
}

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

private static Frame getFrameForFile(Key outputKey, String path,String [] ignores, String response){
 File f = TestUtil.find_test_file(path);
 Key k = NFSFileVec.make(f);
 Frame fr = ParseDataset2.parse(outputKey, new Key[]{k});
 if(ignores != null)
  for(String s:ignores) UKV.remove(fr.remove(s)._key);
 // put the response to the end
 if(response != null)
  fr.add(response, fr.remove(response));
 return fr;
}

相关文章