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

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

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

Frame.names介绍

暂无

代码示例

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

void foldColumnIsInEncodingMapCheck(String foldColumnName, Frame targetEncodingMap) {
  if(foldColumnName == null && targetEncodingMap.names().length > 3) {
    throw new IllegalStateException("Passed along encoding map possibly contains fold column. Please provide fold column name so that it becomes possible to regroup (by ignoring folds).");
  }
}

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

static Frame renameColumn(Frame fr, int indexOfColumnToRename, String newName) {
 String[] updatedtNames = fr.names();
 updatedtNames[indexOfColumnToRename] = newName;
 fr.setNames(updatedtNames);
 return fr;
}

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

/** Full constructor from frame: Strips out the Vecs to just the names needed
 *  to match columns later for future datasets.
 */
public Model( Key selfKey, Key dataKey, Frame fr, float[] priorClassDist ) {
 this(selfKey,dataKey,fr.names(),fr.domains(), priorClassDist, null, 0, 0);
}
public Model( Key selfKey, Key dataKey, String names[], String domains[][], float[] priorClassDist, float[] modelClassDist) {

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

public FrameMetadata(UserFeedback userFeedback, Frame fr, int response, int[] predictors, String datasetName, boolean isClassification) {
 this(userFeedback, fr, response, intAtoStringA(predictors, fr.names()), datasetName, isClassification);
}

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

public int[] colMap(Frame df) {
 int res[] = new int[df._names.length]; //new int[names.length];
 for(int i = 0; i < res.length; i++) {
  res[i] = find(df.names()[i], _names);
 }
 return res;
}

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

public String[] includedCols() {
 if( _includeCols==null ) {
  if( null==ignoredCols() ) return _includeCols = _fr.names();
  _includeCols = ArrayUtils.difference(_fr.names(), ignoredCols());  // clones _fr.names, so line above avoids one more copy
 }
 return _includeCols;
}

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

protected final Frame selectFrame(Frame frame) {
  Vec[] vecs = new Vec[cols.length];
  String[] names = new String[cols.length];
  for( int i = 0; i < cols.length; i++ ) {
   vecs[i] = frame.vecs()[cols[i]];
   names[i] = frame.names()[cols[i]];
  }
  return new Frame(names, vecs);
 }
}

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

private void setDataInfoToOutput(DataInfo dinfo) {
 if (dinfo == null) return;
 // update the model's expected frame format - needed for train/test adaptation
 _output.setNames(dinfo._adaptedFrame.names());
 _output._domains = dinfo._adaptedFrame.domains();
 _output._nums = dinfo._nums;
 _output._cats = dinfo._cats;
 _output._catOffsets = dinfo._catOffsets;
 _output._normMul = dinfo._normMul;
 _output._normSub = dinfo._normSub;
 _output._normRespMul = dinfo._normRespMul;
 _output._normRespSub = dinfo._normRespSub;
 _output._useAllFactorLevels = dinfo._useAllFactorLevels;
}

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

private Frame setTest() {
 if (validation == null) return null;
 Frame test = null;
 ArrayList<Integer> v_ignored_cols = new ArrayList<Integer>();
 for (int ignored_col : ignored_cols) if (validation.find(source.names()[ignored_col]) != -1) v_ignored_cols.add(ignored_col);
 int[] v_ignored = new int[v_ignored_cols.size()];
 for (int i = 0; i < v_ignored.length; ++i) v_ignored[i] = v_ignored_cols.get(i);
 if (validation != null) test = FrameTask.DataInfo.prepareFrame(validation, validation.vecs()[validation.find(source.names()[source.find(response)])], v_ignored, !regression, false, false);
 if (test != null && test.lastVec().masterVec() != null) gtrash(test.lastVec());
 return test;
}
private Frame setStrat(Frame train, Frame test, Vec resp) {

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

@Override public void map(Chunk[] cs) {
 _summaries = new Summary2[cs.length];
 for (int i = 0; i < cs.length; i++)
  _summaries[i] = new Summary2(_fr.vecs()[i], _fr.names()[i], _basics[i], _max_qbins).add(cs[i]);
}
@Override public void reduce(SummaryTask2 other) {

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

private String report() {
 Frame res = UKV.get(dest());
 if (!pairwise)
 return "Created interaction feature " + res.names()[0]
     + " (order: " + factors.length + ") with " + res.lastVec().domain().length + " factor levels"
     + " in" + PrettyPrint.msecs(_time, true);
 else
  return "Created " + res.numCols() + " pair-wise interaction features " + Arrays.deepToString(res.names())
     + " (order: 2) in" + PrettyPrint.msecs(_time, true);
}

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

/** Single row scoring, on a compatible Frame.  */
public final float[] score( Frame fr, boolean exact, int row ) {
 double tmp[] = new double[fr.numCols()];
 for( int i=0; i<tmp.length; i++ )
  tmp[i] = fr.vecs()[i].at(row);
 return score(fr.names(),fr.domains(),exact,tmp);
}

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

@Override
public void compute2() {
 final Vec [] srcVecs = _in.vecs();
 _out = new Frame(_okey,_in.names(), new Vec(_vg.addVec(),_espc).makeZeros(srcVecs.length,_in.domains(),_in.uuids(),_in.times()));
 _out.delete_and_lock(_jobKey);
 new RebalanceTask(this,srcVecs).asyncExec(_out);
}

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

static Vec unifyFrame(DeepLearningParameters drf, Frame fr, PrepData prep, boolean classification) {
 int idx = prep.prep(fr);
 if( idx < 0 ) { idx = ~idx; }
 String rname = fr._names[idx];
 drf._response_column = fr.names()[idx];
 Vec resp = fr.vecs()[idx];
 Vec ret = null;
 if (classification) {
  ret = fr.remove(idx);
  fr.add(rname,resp.toCategoricalVec());
 } else {
  fr.remove(idx);
  fr.add(rname,resp);
 }
 return ret;
}

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

private GLMScore makeScoringTask(Frame adaptFrm, boolean generatePredictions, Job j){
 int responseId = adaptFrm.find(_output.responseName());
 if(responseId > -1 && adaptFrm.vec(responseId).isBad()) { // remove inserted invalid response
  adaptFrm = new Frame(adaptFrm.names(),adaptFrm.vecs());
  adaptFrm.remove(responseId);
 }
 // Build up the names & domains.
 final boolean computeMetrics = adaptFrm.vec(_output.responseName()) != null && !adaptFrm.vec(_output.responseName()).isBad();
 String [] domain = _output.nclasses()<=1 ? null : !computeMetrics ? _output._domains[_output._domains.length-1] : adaptFrm.lastVec().domain();
 // Score the dataset, building the class distribution & predictions
 return new GLMScore(j, this, _output._dinfo.scoringInfo(_output._names,adaptFrm),domain,computeMetrics, generatePredictions);
}
/** Score an already adapted frame.  Returns a new Frame with new result

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

@Override
 public void check(Frame f) {
  assertArrayEquals("Column names need to match!", ar("CEnum", "CUEnum"), f.names());
  assertArrayEquals("Column types need to match!", ar(Vec.T_CAT, Vec.T_CAT), f.types());
  assertArrayEquals("Category names need to match in CEnum!", categories[0], f.vec("CEnum").domain());
  assertArrayEquals("Category names need to match in CUEnum!", categories[1], f.vec("CUEnum").domain());
  int numOfCategories1 = categories[0].length;
  int numOfCategories2 = categories[1].length;
  int nrows = nrows();
  for (int row = 0; row < nrows; row++) {
   assertEquals("Value in column CEnum", row % numOfCategories1, (int) f.vec("CEnum").at(row));
   if (row % (numOfCategories2+1) == 0) assertTrue("NA should be in row " + row + " and col CUEnum", f.vec("CUEnum").isNA(row));
   else assertEquals("Value in column CUEnum", row % numOfCategories2, (int) f.vec("CUEnum").at(row));
  }
 }
}

相关文章