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


Java Frame.names方法代码示例

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


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

示例1: unifyFrame

import water.fvec.Frame; //导入方法依赖的package包/类
static Vec unifyFrame(DRFModel.DRFParameters 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;
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:18,代码来源:DRFTest.java

示例2: unifyFrame

import water.fvec.Frame; //导入方法依赖的package包/类
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;
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:18,代码来源:DeepLearningTest.java

示例3: testModelAdaptMissing

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testModelAdaptMissing() {
  AModel.AParms p = new AModel.AParms();
  AModel.AOutput o = new AModel.AOutput();

  Vec cat = vec(new String[]{"A","B"},0,1,0,1);
  Frame trn = new Frame();
  trn.add("cat",cat);
  o._names = trn.names();
  o._domains = trn.domains();
  trn.remove();
  AModel am = new AModel(Key.make(),p,o);
  
  Frame tst = new Frame();
  tst.add("cat", cat.makeCon(Double.NaN)); // All NAN/missing column
  Frame adapt = new Frame(tst);
  String[] warns = am.adaptTestForTrain(adapt,true, true);
  Assert.assertTrue(warns.length == 0); // No errors during adaption

  Model.cleanup_adapt( adapt, tst );
  tst.remove();
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:22,代码来源:ModelAdaptTest.java

示例4: testModelAdaptConvert

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testModelAdaptConvert() {
  AModel.AParms p = new AModel.AParms();
  AModel.AOutput o = new AModel.AOutput();

  Frame trn = new Frame();
  trn.add("dog",vec(new String[]{"A","B"},0,1,0,1));
  o._names = trn.names();
  o._domains = trn.domains();
  trn.remove();
  AModel am = new AModel(Key.make(),p,o);
  
  Frame tst = new Frame();
  tst.add("dog",vec(2, 3, 2, 3));
  Frame adapt = new Frame(tst);
  boolean saw_iae = false;
  try { am.adaptTestForTrain(adapt, true, true); }
  catch( IllegalArgumentException iae ) { saw_iae = true; }
  Assert.assertTrue(saw_iae);

  Model.cleanup_adapt( adapt, tst );
  tst.remove();
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:23,代码来源:ModelAdaptTest.java

示例5: DTree

import water.fvec.Frame; //导入方法依赖的package包/类
public DTree( Frame fr, int ncols, char nbins, char nbins_cats, char nclass, double min_rows, int mtrys, long seed ) {
  _names = fr.names();
  _ncols = ncols;
  _nbins=nbins;
  _nbins_cats=nbins_cats;
  _nclass=nclass;
  _min_rows = min_rows;
  _ns = new Node[1];
  _mtrys = mtrys;
  _seed = seed;
  _rand = SharedTree.createRNG(seed);
  _seeds = new long[fr.vecs()[0].nChunks()];
  for (int i = 0; i < _seeds.length; i++)
    _seeds[i] = _rand.nextLong();
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:16,代码来源:DTree.java

示例6: transform

import water.fvec.Frame; //导入方法依赖的package包/类
public Frame transform(Frame f) {
  _inNames = f.names();
  _inTypes = f.typesStr();
  Frame ff = transformImpl(f);
  _outTypes= ff.typesStr();
  return ff;
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:8,代码来源:Transform.java

示例7: execute

import water.fvec.Frame; //导入方法依赖的package包/类
public static Val execute(AST ast) {
  // Execute
  Env env = new Env();
  Val val = ast.exec(env);
  // Results.  Deep copy returned Vecs.  Always return a key-less Frame
  if( val.isFrame() ) {
    Frame fr = val.getFrame();
    if( fr._key != null ) val=new ValFrame(fr = new Frame(null,fr.names(),fr.vecs()));
    Vec vecs[] = fr.vecs();
    for( int i=0; i<vecs.length; i++ )
      if( env.isPreExistingGlobal(vecs[i]) )
        fr.replace(i,vecs[i].makeCopy());
  }
  return val;
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:16,代码来源:Exec.java

示例8: toString

import water.fvec.Frame; //导入方法依赖的package包/类
@Override public String toString() {
  Frame res = get();
  if (res == null) return "Output frame not found";

  if (!_pairwise)
    return "Created interaction feature " + res.names()[0]
            + " (order: " + _factors.length + ") with " + res.lastVec().domain().length + " factor levels"
            + " in" + PrettyPrint.msecs(_end_time-_start_time, true);
  else
    return "Created " + res.numCols() + " pair-wise interaction features " + Arrays.deepToString(res.names())
            + " (order: 2) in" + PrettyPrint.msecs(_end_time-_start_time, true);
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:13,代码来源:Interaction.java

示例9: run

import water.fvec.Frame; //导入方法依赖的package包/类
@Test
public void run() {
  // Put chunks into KV store
  Frame f = new TestUtil().parse_test_file("smalldata/junit/syn_2659x1049.csv.gz");
  // Create two lockable frames in KV store
  Frame fr1 = new Frame(Key.make(), f.names(), f.vecs());
  Frame fr2 = new Frame(Key.make(), f.names(), f.vecs());
  // Lock the frames against writes
  fr1.delete_and_lock(null);
  fr2.delete_and_lock(null);
  int i = 0;
  try {
    // try to delete the write-locked frames -> will throw an exception
    fr1.delete();
    fr2.delete(); // won't be reached
  } catch (Throwable t) {
    Log.info("Correctly unable to delete (was locked): " + t.getClass()); //either AssertionError if local or DistributedException if remote
    i++;
  } finally {
    // second attempt: will unlock and delete properly
    new UnlockTask().doAllNodes(); // without this line, there will be a leak (and assertion won't be shown)
    fr1.delete();
    fr2.delete();
    f.delete();
    Log.info("Able to delete after unlocking.");
  }
  Assert.assertTrue(i == 1);
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:29,代码来源:UnlockTest.java

示例10: testModelAdaptMultinomial

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testModelAdaptMultinomial() {
  Frame trn = parse_test_file("smalldata/junit/mixcat_train.csv");
  AModel.AParms p = new AModel.AParms();
  AModel.AOutput o = new AModel.AOutput();
  o._names = trn.names();
  o._domains = trn.domains();
  trn.remove();
  AModel am = new AModel(Key.make(),p,o);
  
  Frame tst = parse_test_file("smalldata/junit/mixcat_test.csv");
  Frame adapt = new Frame(tst);
  String[] warns = am.adaptTestForTrain(adapt,true, true);
  Assert.assertTrue(ArrayUtils.find(warns,"Test/Validation dataset column 'Feature_1' has levels not trained on: [D]")!= -1);
  Assert.assertTrue(ArrayUtils.find(warns, "Test/Validation dataset is missing training column 'Const': substituting in a column of NAs") != -1);
  Assert.assertTrue(ArrayUtils.find(warns, "Test/Validation dataset is missing training column 'Useless': substituting in a column of NAs") != -1);
  Assert.assertTrue(ArrayUtils.find(warns, "Test/Validation dataset column 'Response' has levels not trained on: [W]") != -1);
  // Feature_1: merged test & train domains
  Assert.assertArrayEquals(adapt.vec("Feature_1").domain(),new String[]{"A","B","C","D"});
  // Const: all NAs
  Assert.assertTrue(adapt.vec("Const").isBad());
  // Useless: all NAs
  Assert.assertTrue(adapt.vec("Useless").isBad());
  // Response: merged test & train domains
  Assert.assertArrayEquals(adapt.vec("Response").domain(),new String[]{"X","Y","Z","W"});

  Model.cleanup_adapt( adapt, tst );
  tst.remove();
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:29,代码来源:ModelAdaptTest.java

示例11: testImputeMissing

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testImputeMissing() throws InterruptedException, ExecutionException {
  Frame train = null;
  double missing_fraction = 0.75;
  long seed = 12345;

  try {
    train = parse_test_file(Key.make("arrests.hex"), "smalldata/pca_test/USArrests.csv");
    // Add missing values to the training data
    if (missing_fraction > 0) {
      Frame frtmp = new Frame(Key.make(), train.names(), train.vecs());
      DKV.put(frtmp._key, frtmp); // Need to put the frame (to be modified) into DKV for MissingInserter to pick up
      FrameUtils.MissingInserter j = new FrameUtils.MissingInserter(frtmp._key, seed, missing_fraction);
      j.execImpl();
      j.get(); // MissingInserter is non-blocking, must block here explicitly
      DKV.remove(frtmp._key); // Delete the frame header (not the data)
    }

    PCAModel.PCAParameters parms = new PCAModel.PCAParameters();
    parms._train = train._key;
    parms._k = 4;
    parms._transform = DataInfo.TransformType.NONE;
    parms._pca_method = PCAModel.PCAParameters.Method.GramSVD;
    parms._impute_missing = true;   // Don't skip rows with NA entries, but impute using mean of column
    parms._seed = seed;

    PCAModel pca = null;
    PCA job = null;
    try {
      job = new PCA(parms);
      pca = job.trainModel().get();
    } finally {
      if (job != null) job.remove();
      if (pca != null) pca.remove();
    }
  } catch(Throwable t) {
    t.printStackTrace();
    throw new RuntimeException(t);
  } finally {
    if (train != null) train.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:42,代码来源:PCATest.java

示例12: run

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void run() {
    Scope.enter();
    NFSFileVec  nfs = NFSFileVec.make(find_test_file("smalldata/junit/two_spiral.csv"));
    Frame frame = ParseDataset.parse(Key.make(), nfs._key);
    Log.info(frame);
    int resp = frame.names().length-1;


    for (boolean sparse : new boolean[]{true, false}) {
      for (boolean col_major : new boolean[]{false}) {
        if (!sparse && col_major) continue;

        Key model_id = Key.make();
        // build the model
        {
          DeepLearningParameters p = new DeepLearningParameters();
          p._seed = 0xbabefff;
          p._epochs = 600;
          p._hidden = new int[]{100};
          p._sparse = sparse;
          p._col_major = col_major;
          p._elastic_averaging = false;
          p._activation = DeepLearningParameters.Activation.Tanh;
          p._max_w2 = Float.POSITIVE_INFINITY;
          p._l1 = 0;
          p._l2 = 0;
          p._initial_weight_distribution = DeepLearningParameters.InitialWeightDistribution.Normal;
          p._initial_weight_scale = 2.5;
          p._loss = DeepLearningParameters.Loss.CrossEntropy;
          p._train = frame._key;
          p._response_column = frame.names()[resp];
          Scope.track(frame.replace(resp, frame.vecs()[resp].toCategoricalVec())._key); // Convert response to categorical
          DKV.put(frame);
          p._valid = null;
          p._score_interval = 2;
          p._train_samples_per_iteration = 0; //sync once per period
//          p._quiet_mode = true;
          p._fast_mode = true;
          p._ignore_const_cols = true;
          p._nesterov_accelerated_gradient = true;
          p._score_training_samples = 1000;
          p._score_validation_samples = 10000;
          p._shuffle_training_data = false;
          p._force_load_balance = false;
          p._replicate_training_data = false;
          p._model_id = model_id;
          p._adaptive_rate = true;
          p._reproducible = true;
          p._rho = 0.99;
          p._epsilon = 5e-3;
          DeepLearning dl = new DeepLearning(p);
          try {
            dl.trainModel().get();
          } catch (Throwable t) {
            t.printStackTrace();
            throw new RuntimeException(t);
          } finally {
            dl.remove();
          }
        }

        // score and check result
        {
          DeepLearningModel mymodel = DKV.getGet(model_id);
          Frame pred = mymodel.score(frame);
          ModelMetricsBinomial mm = ModelMetricsBinomial.getFromDKV(mymodel,frame);
          double error = mm._auc.defaultErr();
          Log.info("Error: " + error);
          if (error > 0) {
            Assert.fail("Classification error is not 0, but " + error + ".");
          }
          Assert.assertTrue(mymodel.testJavaScoring(frame,pred,1e-6));
          pred.delete();
          mymodel.delete();
        }
      }
    }
    frame.delete();
    Scope.exit();
  }
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:81,代码来源:DeepLearningSpiralsTest.java


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