当前位置: 首页>>代码示例>>Java>>正文


Java Frame.find方法代码示例

本文整理汇总了Java中water.fvec.Frame.find方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.find方法的具体用法?Java Frame.find怎么用?Java Frame.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在water.fvec.Frame的用法示例。


在下文中一共展示了Frame.find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: predictScoreImpl

import water.fvec.Frame; //导入方法依赖的package包/类
/** Score an already adapted frame.  Returns a new Frame with new result
 *  vectors, all in the DKV.  Caller responsible for deleting.  Input is
 *  already adapted to the Model's domain, so the output is also.  Also
 *  computes the metrics for this frame.
 *
 * @param adaptFrm Already adapted frame
 * @return A Frame containing the prediction column, and class distribution
 */
protected Frame predictScoreImpl(Frame fr, Frame adaptFrm, String destination_key) {
  final boolean computeMetrics = (!isSupervised() || adaptFrm.find(_output.responseName()) != -1);
  // Build up the names & domains.
  final int nc = _output.nclasses();
  final int ncols = nc==1?1:nc+1; // Regression has 1 predict col; classification also has class distribution
  String[] names = new String[ncols];
  String[][] domains = new String[ncols][];
  names[0] = "predict";
  for(int i = 1; i < names.length; ++i) {
    names[i] = _output.classNames()[i - 1];
    // turn integer class labels such as 0, 1, etc. into p0, p1, etc.
    try {
      Integer.valueOf(names[i]);
      names[i] = "p" + names[i];
    } catch (Throwable t) {
      // do nothing, non-integer names are fine already
    }
  }
  domains[0] = nc==1 ? null : !computeMetrics ? _output._domains[_output._domains.length-1] : adaptFrm.lastVec().domain();
  // Score the dataset, building the class distribution & predictions
  BigScore bs = new BigScore(domains[0],ncols,adaptFrm.means(),_output.hasWeights() && adaptFrm.find(_output.weightsName()) >= 0,computeMetrics, true /*make preds*/).doAll_numericResult(ncols,adaptFrm);
  if (computeMetrics)
    bs._mb.makeModelMetrics(this, fr);
  return bs.outputFrame((null == destination_key ? Key.make() : Key.make(destination_key)), names, domains);
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:34,代码来源:Model.java

示例2: scoreMetrics

import water.fvec.Frame; //导入方法依赖的package包/类
/** Score an already adapted frame.  Returns a MetricBuilder that can be used to make a model metrics.
 * @param adaptFrm Already adapted frame
 * @return MetricBuilder
 */
protected ModelMetrics.MetricBuilder scoreMetrics(Frame adaptFrm) {
  final boolean computeMetrics = (!isSupervised() || adaptFrm.find(_output.responseName()) != -1);
  // Build up the names & domains.
  final int nc = _output.nclasses();
  final int ncols = nc==1?1:nc+1; // Regression has 1 predict col; classification also has class distribution
  String[] names = new String[ncols];
  String[][] domains = new String[ncols][];
  names[0] = "predict";
  for(int i = 1; i < names.length; ++i) {
    names[i] = _output.classNames()[i - 1];
    // turn integer class labels such as 0, 1, etc. into p0, p1, etc.
    try {
      Integer.valueOf(names[i]);
      names[i] = "p" + names[i];
    } catch (Throwable t) {
      // do nothing, non-integer names are fine already
    }
  }
  domains[0] = nc==1 ? null : !computeMetrics ? _output._domains[_output._domains.length-1] : adaptFrm.lastVec().domain();
  // Score the dataset, building the class distribution & predictions
  BigScore bs = new BigScore(domains[0],ncols,adaptFrm.means(),_output.hasWeights() && adaptFrm.find(_output.weightsName()) >= 0,computeMetrics, false /*no preds*/).doAll(adaptFrm);
  return bs._mb;
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:28,代码来源:Model.java

示例3: execImpl

import water.fvec.Frame; //导入方法依赖的package包/类
public Frame execImpl() {
  try {
    Frame source_frame = DKV.getGet(_source_frame);
    assert(source_frame != null);
    if (_factor_columns == null || _factor_columns.length == 0) throw new IllegalArgumentException("factor_columns must be specified.");
    if (_pairwise && _factor_columns.length < 3) Log.info("Ignoring the pairwise option, requires 3 or more factors.");
    _factors = new int[_factor_columns.length];
    int count=0;
    for (String v: _factor_columns) {
      int idx = source_frame.find(v);
      if (idx >= 0) {
        if (!source_frame.vecs()[idx].isCategorical()) {
          throw new IllegalArgumentException("Column " + v + " is not categorical.");
        }
        _factors[count++] = idx;
      } else {
        throw new IllegalArgumentException("Column " + v + " not found.");
      }
    }
    CreateInteractions in = new CreateInteractions(this, this._key);
    return start(in, in.work(), true).get();
  } catch( Throwable t ) {
    throw t;
  } finally {
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:27,代码来源:Interaction.java

示例4: score

import water.fvec.Frame; //导入方法依赖的package包/类
/** Bulk score the frame {@code fr}, producing a Frame result; the 1st
   *  Vec is the predicted class, the remaining Vecs are the probability
   *  distributions.  For Regression (single-class) models, the 1st and only
   *  Vec is the prediction value.  The result is in the DKV; caller is
   *  responsible for deleting.
   *
   * @param fr frame which should be scored
   * @return A new frame containing a predicted values. For classification it
   *         contains a column with prediction and distribution for all
   *         response classes. For regression it contains only one column with
   *         predicted values.
   * @throws IllegalArgumentException
   */
  public Frame score(Frame fr, String destination_key) throws IllegalArgumentException {
    Frame adaptFr = new Frame(fr);
    boolean computeMetrics = (!isSupervised() || adaptFr.find(_output.responseName()) != -1);
    adaptTestForTrain(adaptFr,true, computeMetrics);   // Adapt
    Frame output = predictScoreImpl(fr, adaptFr, destination_key); // Predict & Score
    // Log modest confusion matrices
    Vec predicted = output.vecs()[0]; // Modeled/predicted response
    String mdomain[] = predicted.domain(); // Domain of predictions (union of test and train)

    // Output is in the model's domain, but needs to be mapped to the scored
    // dataset's domain.
    if(_output.isClassifier() && computeMetrics) {
//      assert(mdomain != null); // label must be categorical
      ModelMetrics mm = ModelMetrics.getFromDKV(this,fr);
      ConfusionMatrix cm = mm.cm();
      if (cm != null && cm._domain != null) //don't print table for regression
        if( cm._cm.length < _parms._max_confusion_matrix_size/*Print size limitation*/ ) {
          Log.info(cm.table().toString(1));
        }
      if (mm.hr() != null) {
        Log.info(getHitRatioTable(mm.hr()));
      }
      Vec actual = fr.vec(_output.responseName());
      if( actual != null ) {  // Predict does not have an actual, scoring does
        String sdomain[] = actual.domain(); // Scored/test domain; can be null
        if (sdomain != null && mdomain != sdomain && !Arrays.equals(mdomain, sdomain))
          output.replace(0, new CategoricalWrappedVec(actual.group().addVec(), actual._rowLayout, sdomain, predicted._key));
      }
    }

    cleanup_adapt(adaptFr, fr);
    return output;
  }
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:47,代码来源:Model.java

示例5: cleanup_adapt

import water.fvec.Frame; //导入方法依赖的package包/类
static protected void cleanup_adapt( Frame adaptFr, Frame fr ) {
  Key[] keys = adaptFr.keys();
  for( int i=0; i<keys.length; i++ )
    if( fr.find(keys[i]) != -1 ) // Exists in the original frame?
      keys[i] = null;            // Do not delete it
  adaptFr.delete();
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:8,代码来源:Model.java


注:本文中的water.fvec.Frame.find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。