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


Java Frame.remove方法代码示例

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


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

示例1: doIt

import water.fvec.Frame; //导入方法依赖的package包/类
void doIt( Frame f, String msg, boolean expensive ) {
  boolean any=false;
  for( int i = 0; i < f.vecs().length - _specialVecs; i++ ) {
    if( filter(f.vecs()[i]) ) {
      if( any ) msg += ", "; // Log dropped cols
      any = true;
      msg += f._names[i];
      f.remove(i);
      i--; // Re-run at same iteration after dropping a col
    }
  }
  if( any ) {
    warn("_train", msg);
    if (expensive) Log.info(msg);
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:17,代码来源:ModelBuilder.java

示例2: testInts

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testInts() {
  QuantileModel kmm = null;
  Frame fr = null;
  try {
    fr = ArrayUtils.frame(new double[][]{{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
                                          {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1},
                                          {2}, {2}, {2}, {2}, {2}, {2}, {2}, {2}, {2}, {2}});

    QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
    parms._train = fr._key;

    Job<QuantileModel> job = new Quantile(parms).trainModel();
    kmm = job.get();
    job.remove();

  } finally {
    if( fr  != null ) fr .remove();
    if( kmm != null ) kmm.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:21,代码来源:QuantileTest.java

示例3: test50pct

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void test50pct() {
  QuantileModel kmm = null;
  Frame fr = null;
  try {
    double[][] d = new double[][]{{1.56386606237}, {0.812834256224}, {3.68417563302}, {3.12702210880}, {5.51277746586}};
    fr = ArrayUtils.frame(d);
    QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
    parms._train = fr._key;
    Job<QuantileModel> job = new Quantile(parms).trainModel();
    kmm = job.get();
    job.remove();
    Assert.assertTrue(kmm._output._quantiles[0][5]==d[3][0]);

  } finally {
    if( fr  != null ) fr .remove();
    if( kmm != null ) kmm.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:19,代码来源:QuantileTest.java

示例4: 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

示例5: 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

示例6: testW2V_CBOW_HSM

import water.fvec.Frame; //导入方法依赖的package包/类
@Ignore
@Test public void testW2V_CBOW_HSM() {
  Word2Vec job = null;
  Word2VecModel w2vm = null;
  Frame fr = null;
  try {
    fr = parse_test_file(testFName);

    Word2VecModel.Word2VecParameters parms = new Word2VecModel.Word2VecParameters();
    parms._train = fr._key;
    parms._minWordFreq = 20;
    parms._wordModel = Word2Vec.WordModel.CBOW;
    parms._normModel = Word2Vec.NormModel.HSM;
    parms._vecSize = 100;
    parms._windowSize = 4;
    parms._sentSampleRate = 0.01f;
    parms._initLearningRate = 0.05f;
    parms._epochs = 25;
    job = new Word2Vec(parms);
    job.trainModel();
    w2vm = job.get();
    HashMap hm = w2vm.findSynonyms("dog",10);
    printResults(hm);
    Assert.assertTrue(hm.containsKey("dogs"));
  } finally {
    if( fr  != null ) fr .remove();
    if( job != null) job.remove();
    if( w2vm != null) w2vm.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:31,代码来源:Word2VecTest.java

示例7: testW2V_CBOW_NS

import water.fvec.Frame; //导入方法依赖的package包/类
@Ignore
@Test public void testW2V_CBOW_NS() {
  Word2Vec job = null;
  Word2VecModel w2vm = null;
  Frame fr = null;
  try {
    fr = parse_test_file(testFName);

    Word2VecModel.Word2VecParameters parms = new Word2VecModel.Word2VecParameters();
    parms._train = fr._key;
    parms._minWordFreq = 20;
    parms._wordModel = Word2Vec.WordModel.CBOW;
    parms._normModel = Word2Vec.NormModel.NegSampling;
    parms._negSampleCnt = 15;
    parms._vecSize = 100;
    parms._windowSize = 4;
    parms._sentSampleRate = 0.01f;
    parms._initLearningRate = 0.05f;
    parms._epochs = 15;
    job = new Word2Vec(parms);
    job.train();
    w2vm = job.get();
    HashMap hm = w2vm.findSynonyms("dog",10);
    printResults(hm);
    Assert.assertTrue(hm.containsKey("dogs"));
  } finally {
    if( fr  != null ) fr .remove();
    if( job != null) job.remove();
    if( w2vm != null) w2vm.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:32,代码来源:Word2VecTest.java

示例8: testW2V_SG_NS

import water.fvec.Frame; //导入方法依赖的package包/类
@Ignore
@Test public void testW2V_SG_NS() {
  Word2Vec job = null;
  Word2VecModel w2vm = null;
  Frame fr = null;
  try {
    fr = parse_test_file(testFName);

    Word2VecModel.Word2VecParameters parms = new Word2VecModel.Word2VecParameters();
    parms._train = fr._key;
    parms._minWordFreq = 20;
    parms._wordModel = Word2Vec.WordModel.SkipGram;
    parms._normModel = Word2Vec.NormModel.NegSampling;
    parms._negSampleCnt = 5;
    parms._vecSize = 100;
    parms._windowSize = 4;
    parms._sentSampleRate = 0.001f;
    parms._initLearningRate = 0.025f;
    parms._epochs = 15;
    job = new Word2Vec(parms);
    job.train();
    w2vm = job.get();
    HashMap hm = w2vm.findSynonyms("dog",10);
    printResults(hm);
    Assert.assertTrue(hm.containsKey("dogs"));
  } finally {
    if( fr  != null ) fr .remove();
    if( job != null) job.remove();
    if( w2vm != null) w2vm.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:32,代码来源:Word2VecTest.java

示例9: testCollisionOfDRFParamsChecksum

import water.fvec.Frame; //导入方法依赖的package包/类
@Test
public void testCollisionOfDRFParamsChecksum() {
  Frame fr = null;
  try {
    fr = parse_test_file("smalldata/junit/cars.csv");
    fr.remove("name").remove();
    Vec old = fr.remove("economy (mpg)");
    fr.add("economy (mpg)", old); // response to last column
    DKV.put(fr);

    // {"_model_id":null,"_train":{"name":"_83da9e0754c5eb9f6b812fe17e7945e5","type":"Key"},"_valid":null,"_nfolds":0,"_keep_cross_validation_predictions":false,"_fold_assignment":"AUTO","_distribution":"AUTO","_tweedie_power":1.5,"_ignored_columns":null,"_ignore_const_cols":true,"_weights_column":null,"_offset_column":null,"_fold_column":null,"_score_each_iteration":false,"_response_column":"economy (mpg)","_balance_classes":false,"_max_after_balance_size":5.0,"_class_sampling_factors":null,"_max_hit_ratio_k":10,"_max_confusion_matrix_size":20,"_checkpoint":null,"_ntrees":9,"_max_depth":15,"_min_rows":1.0,"_nbins":20,"_nbins_cats":1024,"_r2_stopping":0.999999,"_seed":-4522296119273841674,"_nbins_top_level":1024,"_build_tree_one_node":false,"_initial_score_interval":4000,"_score_interval":4000,"_mtries":3,"_sample_rate":0.6499997,"_binomial_double_trees":false}
    DRFModel.DRFParameters params1 = new DRFModel.DRFParameters();
    params1._train = fr._key;
    params1._response_column = "economy (mpg)";
    params1._seed = -4522296119273841674L;
    params1._mtries = 3;
    params1._max_depth = 15;
    params1._ntrees = 9;
    params1._sample_rate = 0.6499997f;

    // {"_model_id":null,"_train":{"name":"_83da9e0754c5eb9f6b812fe17e7945e5","type":"Key"},"_valid":null,"_nfolds":0,"_keep_cross_validation_predictions":false,"_fold_assignment":"AUTO","_distribution":"AUTO","_tweedie_power":1.5,"_ignored_columns":null,"_ignore_const_cols":true,"_weights_column":null,"_offset_column":null,"_fold_column":null,"_score_each_iteration":false,"_response_column":"economy (mpg)","_balance_classes":false,"_max_after_balance_size":5.0,"_class_sampling_factors":null,"_max_hit_ratio_k":10,"_max_confusion_matrix_size":20,"_checkpoint":null,"_ntrees":13,"_max_depth":1,"_min_rows":1.0,"_nbins":20,"_nbins_cats":1024,"_r2_stopping":0.999999,"_seed":-4522296119273841674,"_nbins_top_level":1024,"_build_tree_one_node":false,"_initial_score_interval":4000,"_score_interval":4000,"_mtries":1,"_sample_rate":0.6499997,"_binomial_double_trees":false}
    DRFModel.DRFParameters params2 = new DRFModel.DRFParameters();
    params2._train = fr._key;
    params2._response_column = "economy (mpg)";
    params2._seed = -4522296119273841674L;
    params2._mtries = 1;
    params2._max_depth = 1;
    params2._ntrees = 13;
    params2._sample_rate = 0.6499997f;
    long csum1 = params1.checksum();
    long csum2 = params2.checksum();
    Assert.assertNotEquals("Checksums shoudl be different", csum1, csum2);
  } finally {
    if (fr != null) {
      fr.remove();
    }
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:39,代码来源:DRFGridTest.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: main

import water.fvec.Frame; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  initCloud();

  // Load and parse a file. Data is distributed to other nodes in a round-robin way
  File f = new File("smalldata/glm_test/gaussian.csv");
  NFSFileVec nfs = NFSFileVec.make(f);
  Frame frame = water.parser.ParseDataset.parse(Key.make(),nfs._key);

  // Optionally create a frame with fewer columns, e.g. skip first
  frame.remove(0);

  // Create k centers as arrays of doubles
  int k = 7;
  double[][] centers = new double[k][frame.vecs().length];

  // Initialize first cluster center to random row
  Random rand = new Random();
  for( int cluster = 0; cluster < centers.length; cluster++ ) {
    long row = Math.max(0, (long) (rand.nextDouble() * frame.vecs().length) - 1);
    for( int i = 0; i < frame.vecs().length; i++ ) {
      Vec v = frame.vecs()[i];
      centers[cluster][i] = v.at(row);
    }
  }

  // Iterate over the dataset and show error for each step
  int NUM_ITERS = 10;
  for( int i = 0; i < NUM_ITERS; i++ ) {
    KMeans task = new KMeans();
    task._centers = centers;
    task.doAll(frame);

    for( int c = 0; c < centers.length; c++ ) {
      if( task._size[c] > 0 ) {
        for( int v = 0; v < frame.vecs().length; v++ ) {
          double value = task._sums[c][v] / task._size[c];
          centers[c][v] = value;
        }
      }
    }
    System.out.println("Error is " + task._error);
  }

  System.out.println("Cluster Centers:");
  DecimalFormat df = new DecimalFormat("#.00");
  for (double[] center : centers) {
    for (int v = 0; v < frame.vecs().length; v++)
      System.out.print(df.format(center[v]) + ", ");
    System.out.println("");
  }

  System.exit(0);
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:54,代码来源:KMeansDroplet.java

示例12: basicDL

import water.fvec.Frame; //导入方法依赖的package包/类
public void basicDL(String fnametrain, String hexnametrain, String fnametest, PrepData prep, int epochs, double[][] expCM, String[] expRespDom, double expMSE, int[] hidden, double l1, boolean classification, DeepLearningParameters.Activation activation) throws Throwable {
  Scope.enter();
  DeepLearningParameters dl = new DeepLearningParameters();
  Frame frTest = null, pred = null;
  Frame frTrain = null;
  Frame test = null, res = null;
  DeepLearningModel model = null;
  try {
    frTrain = parse_test_file(fnametrain);
    Vec removeme = unifyFrame(dl, frTrain, prep, classification);
    if (removeme != null) Scope.track(removeme._key);
    DKV.put(frTrain._key, frTrain);
    // Configure DL
    dl._train = frTrain._key;
    dl._response_column = ((Frame)DKV.getGet(dl._train)).lastVecName();
    dl._seed = (1L<<32)|2;
    dl._model_id = Key.make("DL_model_" + hexnametrain);
    dl._reproducible = true;
    dl._epochs = epochs;
    dl._activation = activation;
    dl._export_weights_and_biases = true;
    dl._hidden = hidden;
    dl._l1 = l1;
    dl._elastic_averaging = false;

    // Invoke DL and block till the end
    DeepLearning job = null;
    try {
      job = new DeepLearning(dl);
      // Get the model
      model = job.trainModel().get();
      Log.info(model._output);
    } finally {
      if (job != null) job.remove();
    }
    assertTrue(job._state == Job.JobState.DONE); //HEX-1817

    hex.ModelMetrics mm;
    if (fnametest != null) {
      frTest = parse_test_file(fnametest);
      pred = model.score(frTest);
      mm = hex.ModelMetrics.getFromDKV(model, frTest);
      // Check test set CM
    } else {
      pred = model.score(frTrain);
      mm = hex.ModelMetrics.getFromDKV(model, frTrain);
    }

    test = parse_test_file(fnametrain);
    res = model.score(test);

    if (classification) {
      assertTrue("Expected: " + Arrays.deepToString(expCM) + ", Got: " + Arrays.deepToString(mm.cm()._cm),
          Arrays.deepEquals(mm.cm()._cm, expCM));

      String[] cmDom = model._output._domains[model._output._domains.length - 1];
      Assert.assertArrayEquals("CM domain differs!", expRespDom, cmDom);
      Log.info("\nTraining CM:\n" + mm.cm().toASCII());
      Log.info("\nTraining CM:\n" + hex.ModelMetrics.getFromDKV(model, test).cm().toASCII());
    } else {
      assertTrue("Expected: " + expMSE + ", Got: " + mm.mse(), MathUtils.compare(expMSE, mm.mse(), 1e-8, 1e-8));
      Log.info("\nOOB Training MSE: " + mm.mse());
      Log.info("\nTraining MSE: " + hex.ModelMetrics.getFromDKV(model, test).mse());
    }

    hex.ModelMetrics.getFromDKV(model, test);

    // Build a POJO, validate same results
    assertTrue(model.testJavaScoring(test, res, 1e-5));

  } finally {
    if (frTrain!=null) frTrain.remove();
    if (frTest!=null) frTest.remove();
    if( model != null ) model.delete(); // Remove the model
    if( pred != null ) pred.delete();
    if( test != null ) test.delete();
    if( res != null ) res.delete();
    Scope.exit();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:81,代码来源:DeepLearningTest.java

示例13: testCheckpointReconstruction4BinomialPUBDEV1829

import water.fvec.Frame; //导入方法依赖的package包/类
@Ignore("PUBDEV-1829")
public void testCheckpointReconstruction4BinomialPUBDEV1829() {
  Frame tr = parse_test_file("smalldata/jira/gbm_checkpoint_train.csv");
  Frame val = parse_test_file("smalldata/jira/gbm_checkpoint_valid.csv");

  Vec old = null;

  tr.remove("name").remove();
  tr.remove("economy").remove();
  val.remove("name").remove();
  val.remove("economy").remove();

  old = tr.remove("economy_20mpg");
  tr.add("economy_20mpg", old);
  DKV.put(tr);

  old = val.remove("economy_20mpg");
  val.add("economy_20mpg", old);
  DKV.put(val);

  GBMModel model = null;
  GBMModel modelFromCheckpoint = null;
  GBMModel modelFinal = null;

  try {
    GBMModel.GBMParameters gbmParams = new GBMModel.GBMParameters();
    gbmParams._model_id = Key.make("Initial model");
    gbmParams._train = tr._key;
    gbmParams._valid = val._key;
    gbmParams._response_column = "economy_20mpg";
    gbmParams._ntrees = 5;
    gbmParams._max_depth = 5;
    gbmParams._min_rows = 10;
    gbmParams._score_each_iteration = true;
    gbmParams._seed = 42;
    model = new GBM(gbmParams).trainModel().get();

    GBMModel.GBMParameters gbmFromCheckpointParams = new GBMModel.GBMParameters();
    gbmFromCheckpointParams._model_id = Key.make("Model from checkpoint");
    gbmFromCheckpointParams._train = tr._key;
    gbmFromCheckpointParams._valid = val._key;
    gbmFromCheckpointParams._response_column = "economy_20mpg";
    gbmFromCheckpointParams._ntrees = 10;
    gbmFromCheckpointParams._checkpoint = model._key;
    gbmFromCheckpointParams._score_each_iteration = true;
    gbmFromCheckpointParams._max_depth = 5;
    gbmFromCheckpointParams._min_rows = 10;
    gbmFromCheckpointParams._seed = 42;
    modelFromCheckpoint = new GBM(gbmFromCheckpointParams).trainModel().get();

    // Compute a separated model containing the same number of trees as a model built from checkpoint
    GBMModel.GBMParameters gbmFinalParams = new GBMModel.GBMParameters();
    gbmFinalParams._model_id = Key.make("Validation model");
    gbmFinalParams._train = tr._key;
    gbmFinalParams._valid = val._key;
    gbmFinalParams._response_column = "economy_20mpg";
    gbmFinalParams._ntrees = 10;
    gbmFinalParams._score_each_iteration = true;
    gbmFinalParams._max_depth = 5;
    gbmFinalParams._min_rows = 10;
    gbmFinalParams._seed = 42;
    modelFinal = new GBM(gbmFinalParams).trainModel().get();

    CompressedTree[][] treesFromCheckpoint = getTrees(modelFromCheckpoint);
    CompressedTree[][] treesFromFinalModel = getTrees(modelFinal);
    assertTreeEquals("The model created from checkpoint and corresponding model created from scratch should have the same trees!",
            treesFromCheckpoint, treesFromFinalModel, true);
  } finally {
    if (tr!=null) tr.delete();
    if (val!=null) val.delete();
    if (old != null) old.remove();
    if (model!=null) model.delete();
    if (modelFromCheckpoint!=null) modelFromCheckpoint.delete();
    if (modelFinal!=null) modelFinal.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:77,代码来源:GBMCheckpointTest.java

示例14: elasticAveragingTrivial

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void elasticAveragingTrivial() {
  DeepLearningParameters dl;
  Frame frTrain;
  int N = 2;
  DeepLearningModel [] models = new DeepLearningModel[N];
  dl = new DeepLearningParameters();
  Scope.enter();
  try {
    for (int i = 0; i < N; ++i) {
      frTrain = parse_test_file("./smalldata/covtype/covtype.20k.data");
      Vec resp = frTrain.lastVec().toCategoricalVec();
      frTrain.remove(frTrain.vecs().length - 1).remove();
      frTrain.add("Response", resp);
      DKV.put(frTrain);
      dl._train = frTrain._key;
      dl._response_column = ((Frame) DKV.getGet(dl._train)).lastVecName();
      dl._export_weights_and_biases = true;
      dl._hidden = new int[]{17, 11};
      dl._quiet_mode = false;

      // make it reproducible
      dl._seed = 1234;
      dl._reproducible = true;

      // only do one M/R iteration, and there's no elastic average yet - so the two paths below should be identical
      dl._epochs = 1;
      dl._train_samples_per_iteration = -1;

      if (i == 0) {
        // no elastic averaging
        dl._elastic_averaging = false;
        dl._elastic_averaging_moving_rate = 0.5; //ignored
        dl._elastic_averaging_regularization = 0.9; //ignored
      } else {
        // no-op elastic averaging
        dl._elastic_averaging = true; //go different path, but don't really do anything because of epochs=1 and train_samples_per_iteration=-1
        dl._elastic_averaging_moving_rate = 0.5; //doesn't matter, it's not used since we only do one M/R iteration and there's no time average
        dl._elastic_averaging_regularization = 0.1; //doesn't matter, since elastic average isn't yet available in first iteration
      }

      // Invoke DL and block till the end
      DeepLearning job = null;
      try {
        job = new DeepLearning(dl);
        // Get the model
        models[i] = job.trainModel().get();
      } finally {
        if (job != null) job.remove();
      }
      frTrain.remove();
    }
    for (int i = 0; i < N; ++i) {
      Log.info(models[i]._output._training_metrics.cm().table().toString());
      Assert.assertEquals(models[i]._output._training_metrics._MSE, models[0]._output._training_metrics._MSE, 1e-6);
    }

  }finally{
    for (int i=0; i<N; ++i)
      if (models[i] != null)
        models[i].delete();
    Scope.exit();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:64,代码来源:DeepLearningTest.java

示例15: testReproducibility

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testReproducibility() {
    Frame tfr=null;
    final int N = 5;
    double[] mses = new double[N];

    Scope.enter();
    try {
      // Load data, hack frames
      tfr = parse_test_file("smalldata/covtype/covtype.20k.data");

      // rebalance to 256 chunks
      Key dest = Key.make("df.rebalanced.hex");
      RebalanceDataSet rb = new RebalanceDataSet(tfr, dest, 256);
      H2O.submitTask(rb);
      rb.join();
      tfr.delete();
      tfr = DKV.get(dest).get();
//      Scope.track(tfr.replace(54, tfr.vecs()[54].toCategoricalVec())._key);
//      DKV.put(tfr);

      for (int i=0; i<N; ++i) {
        DRFModel.DRFParameters parms = new DRFModel.DRFParameters();
        parms._train = tfr._key;
        parms._response_column = "C55";
        parms._nbins = 1000;
        parms._ntrees = 1;
        parms._max_depth = 8;
        parms._mtries = -1;
        parms._min_rows = 10;
        parms._seed = 1234;

        // Build a first model; all remaining models should be equal
        DRF job = new DRF(parms);
        DRFModel drf = job.trainModel().get();
        assertEquals(drf._output._ntrees, parms._ntrees);

        mses[i] = drf._output._scored_train[drf._output._scored_train.length-1]._mse;
        job.remove();
        drf.delete();
      }
    } finally{
      if (tfr != null) tfr.remove();
    }
    Scope.exit();
    for (int i=0; i<mses.length; ++i) {
      Log.info("trial: " + i + " -> MSE: " + mses[i]);
    }
    for(double mse : mses)
      assertEquals(mse, mses[0], 1e-15);
  }
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:51,代码来源:DRFTest.java


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