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


Java Frame.anyVec方法代码示例

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


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

示例1: apply

import water.fvec.Frame; //导入方法依赖的package包/类
@Override Val apply( Env env, Env.StackHelp stk, AST asts[] ) {
  Frame ary = stk.track(asts[1].exec(env)).getFrame();
  if( ary.numCols() != 1 ) throw new IllegalArgumentException("character requires a single column");
  Vec v0 = ary.anyVec();
  Vec v1 = v0.isString() ? null : v0.toStringVec(); // toCategoricalVec() creates a new vec --> must be cleaned up!
  Frame fr = new Frame(ary._names, new Vec[]{v1 == null ? v0.makeCopy(null) : v1});
  return new ValFrame(fr);
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:9,代码来源:ASTStrList.java

示例2: apply

import water.fvec.Frame; //导入方法依赖的package包/类
@Override Val apply( Env env, Env.StackHelp stk, AST asts[] ) {
  // stack is [ ..., ary, breaks]
  // handle the breaks
  Frame fr2;
  Frame f = stk.track(asts[1].exec(env)).getFrame();
  if( f.numCols() != 1)  throw new IllegalArgumentException("Hist only applies to single numeric columns.");
  Vec vec = f.anyVec();
  if( !vec.isNumeric() ) throw new IllegalArgumentException("Hist only applies to single numeric columns.");

  AST a = asts[2];
  String algo=null;
  int numBreaks=-1;
  double[] breaks=null;

  if( a instanceof ASTStr ) algo=a.str().toLowerCase();
  else if( a instanceof ASTNumList ) breaks=((ASTNumList)a).expand();
  else if( a instanceof ASTNum ) numBreaks = (int)a.exec(env).getNum();

  HistTask t;
  double h;
  double x1=vec.max();
  double x0=vec.min();
  if( breaks != null ) t = new HistTask(breaks,-1,-1/*ignored if _h==-1*/).doAll(vec);
  else if( algo!=null ) {
    switch (algo) {
      case "sturges": numBreaks = sturges(vec); h=(x1-x0)/numBreaks; break;
      case "rice":    numBreaks = rice(vec);    h=(x1-x0)/numBreaks; break;
      case "sqrt":    numBreaks = sqrt(vec);    h=(x1-x0)/numBreaks; break;
      case "doane":   numBreaks = doane(vec);   h=(x1-x0)/numBreaks; break;
      case "scott":   h=scotts_h(vec); numBreaks = scott(vec,h);     break;  // special bin width computation
      case "fd":      h=fds_h(vec);    numBreaks = fd(vec, h);       break;  // special bin width computation
      default:        numBreaks = sturges(vec); h=(x1-x0)/numBreaks;         // just do sturges even if junk passed in
    }
    t = new HistTask(computeCuts(vec,numBreaks),h,x0).doAll(vec);
  }
  else {
    h = (x1-x0)/numBreaks;
    t = new HistTask(computeCuts(vec,numBreaks),h,x0).doAll(vec);
  }
  // wanna make a new frame here [breaks,counts,mids]
  final double[] brks=t._breaks;
  final long  [] cnts=t._counts;
  final double[] mids_true=t._mids;
  final double[] mids = new double[t._breaks.length-1];
  for(int i=1;i<brks.length;++i) mids[i-1] = .5*(t._breaks[i-1]+t._breaks[i]);
  Vec layoutVec = Vec.makeZero(brks.length);
  fr2 = new MRTask() {
    @Override public void map(Chunk[] c, NewChunk[] nc) {
      int start = (int)c[0].start();
      for(int i=0;i<c[0]._len;++i) {
        nc[0].addNum(brks[i+start]);
        if(i==0) {
          nc[1].addNA();
          nc[2].addNA();
          nc[3].addNA();
        } else {
          nc[1].addNum(cnts[(i-1)+start]);
          nc[2].addNum(mids_true[(i-1)+start]);
          nc[3].addNum(mids[(i-1)+start]);
        }
      }
    }
  }.doAll_numericResult(4, new Frame(layoutVec)).outputFrame(null, new String[]{"breaks", "counts", "mids_true", "mids"},null);
  layoutVec.remove();
  return new ValFrame(fr2);
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:67,代码来源:ASTHist.java


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