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


Java Frame.delete方法代码示例

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


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

示例1: testBasic

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testBasic() {
  Frame fr = null;
  String tree = "(GB hex [1] [0] mean 2 \"all\")"; // Group-By on col 1 (not 0), no order-by, mean of col 2
  try {
    fr = chkTree(tree,"smalldata/iris/iris_wheader.csv");
    chkDim(fr,2,23);
    chkFr(fr,0,0,2.0);        // Group 2.0, mean is 3.5
    chkFr(fr,1,0,3.5);
    chkFr(fr,0,1,2.2);        // Group 2.2, mean is 4.5
    chkFr(fr,1,1,4.5);
    chkFr(fr,0,7,2.8);        // Group 2.8, mean is 5.043, largest group
    chkFr(fr,1,7,5.042857142857143);
    chkFr(fr,0,22,4.4);       // Group 4.4, mean is 1.5, last group
    chkFr(fr,1,22,1.5);

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

示例2: prepareGBMModel

import water.fvec.Frame; //导入方法依赖的package包/类
private GBMModel prepareGBMModel(String dataset, String[] ignoredColumns, String response, boolean classification, int ntrees) {
  Frame f = parse_test_file(dataset);
  try {
    if (classification && !f.vec(response).isCategorical()) {
      f.replace(f.find(response), f.vec(response).toCategoricalVec()).remove();
      DKV.put(f._key, f);
    }
    GBMModel.GBMParameters gbmParams = new GBMModel.GBMParameters();
    gbmParams._train = f._key;
    gbmParams._ignored_columns = ignoredColumns;
    gbmParams._response_column = response;
    gbmParams._ntrees = ntrees;
    gbmParams._score_each_iteration = true;
    return new GBM(gbmParams).trainModel().get();
  } finally {
    if (f!=null) f.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:19,代码来源:ModelSerializationTest.java

示例3: prepareDRFModel

import water.fvec.Frame; //导入方法依赖的package包/类
private DRFModel prepareDRFModel(String dataset, String[] ignoredColumns, String response, boolean classification, int ntrees) {
  Frame f = parse_test_file(dataset);
  try {
    if (classification && !f.vec(response).isCategorical()) {
      f.replace(f.find(response), f.vec(response).toCategoricalVec()).remove();
      DKV.put(f._key, f);
    }
    DRFModel.DRFParameters drfParams = new DRFModel.DRFParameters();
    drfParams._train = f._key;
    drfParams._ignored_columns = ignoredColumns;
    drfParams._response_column = response;
    drfParams._ntrees = ntrees;
    drfParams._score_each_iteration = true;
    return new DRF(drfParams).trainModel().get();
  } finally {
    if (f!=null) f.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:19,代码来源:ModelSerializationTest.java

示例4: testEnumSplit

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testEnumSplit(){
  String data1 =
          "@RELATION type\n" +
                  "\n" +
                  "@ATTRIBUTE num ENUM\n" +
                  "\n" +
                  "@DATA\n" +
                  "0\n" +
                  "1.324e-13\n" +
                  "-2\n";
  String data2 =
          "4\n" +
                  "5\n" +
                  "6\n";
  Key k1 = ParserTest.makeByteVec(data1);
  Key k2 = ParserTest.makeByteVec(data2);
  Key[] k = new Key[]{k1, k2};
  Frame fr = ParseDataset.parse(Key.make(), k);
  Assert.assertTrue(fr.anyVec().isCategorical());
  Assert.assertFalse(fr.anyVec().isString());
  Assert.assertTrue(fr.anyVec().cardinality() == 6);
  fr.delete();
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:24,代码来源:ParserTestARFF.java

示例5: testBasic

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testBasic() {
  Frame fr = null;
  String tree = "(rbind 99 a.hex 98)";
  try {
    fr = checkTree(tree);
    Assert.assertEquals(99, fr.vec(0).at(0), Math.ulp(1)); // 1st row 99
    Assert.assertEquals(99, fr.vec(3).at(0), Math.ulp(1)); // 1st row 99

    Assert.assertEquals(5.1, fr.vec(0).at(1), Math.ulp(1)); // 1st row iris
    Assert.assertEquals(0.2, fr.vec(3).at(1), Math.ulp(1)); // 1st row iris

    Assert.assertEquals(5.9, fr.vec(0).at(150), Math.ulp(1)); // last row iris
    Assert.assertEquals(1.8, fr.vec(3).at(150), Math.ulp(1)); // last row iris

    Assert.assertEquals(98, fr.vec(0).at(151), Math.ulp(1)); // last row 98
    Assert.assertEquals(98, fr.vec(3).at(151), Math.ulp(1)); // last row 98
  } finally {
    if( fr != null ) fr.delete();
    Keyed.remove(Key.make("a.hex"));
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:22,代码来源:RBindTest.java

示例6: checkTree

import water.fvec.Frame; //导入方法依赖的package包/类
private void checkTree(String tree, boolean expectThrow) {
  //Frame r = frame(new double[][]{{-1},{1},{2},{3},{4},{5},{6},{254}});
  //Key ahex = Key.make("a.hex");
  //Frame fr = new Frame(ahex, null, new Vec[]{r.remove(0)});
  //r.delete();
  //DKV.put(ahex, fr);
  Frame fr = parse_test_file(Key.make("a.hex"),"smalldata/iris/iris_wheader.csv");
  fr.remove(4).remove();
  try {
    Val val = Exec.exec(tree);
    Assert.assertFalse(expectThrow);
    System.out.println(val.toString());
    if( val instanceof ValFrame ) {
      Frame fr2= ((ValFrame)val)._fr;
      System.out.println(fr2.vec(0));
      fr2.remove();
    }
  } catch( IllegalArgumentException iae ) {
    if( !expectThrow ) throw iae;
  } finally {
    fr.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:24,代码来源:RapidsTest.java

示例7: basicTest3

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void basicTest3() {
  Frame frame = makeFrame(10000);
  Log.info(frame.toString());

  Interaction in = new Interaction();
  in._source_frame = frame._key;
  in._factor_columns = new String[]{"C4","C6","C8"};
  in._max_factors = 20;
  in._min_occurrence = 2;
  in._pairwise = false;
  Frame frame2 = in.execImpl();
  Log.info(frame2.toString());

  frame.delete();
  frame2.delete();
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:17,代码来源:InteractionTest.java

示例8: testTooManyK

import water.fvec.Frame; //导入方法依赖的package包/类
@Test (expected = H2OModelBuilderIllegalArgumentException.class) public void testTooManyK() {
  Frame fr = ArrayUtils.frame(ard(d(1,0),d(0,0),d(1,0),d(2,0),d(0,0),d(0,0)));
  Frame fr2=null;
  KMeansModel kmm = null;
  KMeansModel.KMeansParameters parms;
  try {

    parms = new KMeansModel.KMeansParameters();
    parms._train = fr._key;
    parms._k = 10; //too high -> will throw
    kmm = doSeed(parms, System.nanoTime());
    fr2=kmm.score(fr);
    Assert.assertTrue(kmm.testJavaScoring(fr,fr2,1e-15));
    fr2.delete();

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

示例9: testSplitCats

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testSplitCats() {
  Frame cov = parse_test_file(Key.make("cov"),"smalldata/covtype/covtype.altered.gz");
  System.out.println(cov.toString(0,10));

  Val v_ddply = Exec.exec("(ddply cov [54] nrow)");
  System.out.println(v_ddply.toString());
  ((ValFrame)v_ddply)._fr.delete();

  Val v_groupby = Exec.exec("(GB cov [54] [0] nrow 54 \"all\")");
  System.out.println(v_groupby.toString());
  ((ValFrame)v_groupby)._fr.delete();

  cov.delete();
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:15,代码来源:GroupByTest.java

示例10: testScalarsOnly

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testScalarsOnly() {
  Frame fr = null;
  String tree = "(rbind 99 98)";
  try {
    fr = checkTree(tree);
    Assert.assertEquals(2, fr.numRows());
    Assert.assertEquals(1, fr.numCols());
    Assert.assertEquals(99, fr.vec(0).at(0), Math.ulp(1)); // 1st row 99
    Assert.assertEquals(98, fr.vec(0).at(1), Math.ulp(1)); // 2nd row 98
  } finally {
    if( fr != null ) fr.delete();
    Keyed.remove(Key.make("a.hex"));
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:15,代码来源:RBindTest.java

示例11: testSameFile

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testSameFile() {
  File f = find_test_file("smalldata/iris/iris_wheader.csv");
  NFSFileVec nfs1 = NFSFileVec.make(f);
  NFSFileVec nfs2 = NFSFileVec.make(f);
  Frame fr = null;
  try {
    fr = ParseDataset.parse(Key.make(), new Key[]{nfs1._key, nfs2._key}, false/*delete on done*/, false, ParseSetup.GUESS_HEADER);
  } finally {
    if( fr != null ) fr.delete();
    if( nfs1 != null ) nfs1.remove();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:13,代码来源:ParseFolderTest.java

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

示例13: DCT_2D

import water.fvec.Frame; //导入方法依赖的package包/类
@Test
public void DCT_2D() {
  Frame frame = null;
  Frame frameDCT = null;
  Frame frameRec = null;
  try {
    CreateFrame cf = new CreateFrame();
    cf.rows = 100;
    int height = 47;
    int width = 29;
    int depth = 1;
    cf.cols = height*width*depth;
    cf.categorical_fraction = 0.0;
    cf.integer_fraction = 0;
    cf.binary_fraction = 0;
    cf.missing_fraction = 0;
    cf.factors = 0;
    cf.seed = 1234;
    cf.execImpl();
    cf.get();
    frame = DKV.getGet(cf.dest());
    long now = System.currentTimeMillis();
    frameDCT = MathUtils.DCT.transform2D(frame, height, width, false);
    Log.info("Computed 2D DCT of " + cf.rows + " rows of size " + cf.cols + " in" + PrettyPrint.msecs(System.currentTimeMillis() - now, true));

    now = System.currentTimeMillis();
    frameRec = MathUtils.DCT.transform2D(frameDCT, height, width, true);
    Log.info("Computed inverse 2D DCT of " + cf.rows + " rows of size " + cf.cols + " in" + PrettyPrint.msecs(System.currentTimeMillis() - now, true));

    for (int i=0; i<frame.vecs().length; ++i)
      TestUtil.assertVecEquals(frame.vecs()[i], frameRec.vecs()[i], 1e-5);
    Log.info("Identity test passed: DCT^-1(DCT(frame)) == frame");
  } finally {
    if (frame!=null) frame.delete();
    if (frameDCT!=null) frameDCT.delete();
    if (frameRec!=null) frameRec.delete();
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:39,代码来源:DCTTest.java

示例14: testMulti

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testMulti() {
  Frame fr = null;
  String tree = "(rbind 99 a.hex 98 a.hex 97)";
  try {
    fr = checkTree(tree);
    Assert.assertEquals( 99, fr.vec(0).at(  0), Math.ulp(1)); // 1st row 99
    Assert.assertEquals( 99, fr.vec(3).at(  0), Math.ulp(1)); // 1st row 99

    Assert.assertEquals(5.1, fr.vec(0).at(  1), Math.ulp(1)); // 1st row iris
    Assert.assertEquals(0.2, fr.vec(3).at(  1), Math.ulp(1)); // 1st row iris
    Assert.assertEquals(5.9, fr.vec(0).at(150), Math.ulp(1)); // last row iris
    Assert.assertEquals(1.8, fr.vec(3).at(150), Math.ulp(1)); // last row iris

    Assert.assertEquals( 98, fr.vec(0).at(151), Math.ulp(1)); // last row 98
    Assert.assertEquals( 98, fr.vec(3).at(151), Math.ulp(1)); // last row 98

    Assert.assertEquals(5.1, fr.vec(0).at(152), Math.ulp(1)); // 1st row iris
    Assert.assertEquals(0.2, fr.vec(3).at(152), Math.ulp(1)); // 1st row iris
    Assert.assertEquals(5.9, fr.vec(0).at(301), Math.ulp(1)); // last row iris
    Assert.assertEquals(1.8, fr.vec(3).at(301), Math.ulp(1)); // last row iris

    Assert.assertEquals( 97, fr.vec(0).at(302), Math.ulp(1)); // last row 98
    Assert.assertEquals( 97, fr.vec(3).at(302), Math.ulp(1)); // last row 98

  } finally {
    if( fr != null ) fr.delete();
    Keyed.remove(Key.make("a.hex"));
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:30,代码来源:RBindTest.java

示例15: testStringSplit

import water.fvec.Frame; //导入方法依赖的package包/类
@Test public void testStringSplit(){
  String data1 =
          "@RELATION type\n" +
                  "\n" +
                  "@ATTRIBUTE num STRING\n" +
                  "\n" +
                  "@DATA\n" +
                  "0\n" +
                  "1.324e-13\n" +
                  "-2\n";
  String data2 =
          "4\n" +
                  "5234234234\n" +
                  "6\n";
  Key k1 = ParserTest.makeByteVec(data1);
  Key k2 = ParserTest.makeByteVec(data2);
  Key[] k = new Key[]{k1, k2};
  Frame fr = ParseDataset.parse(Key.make(), k);
  Assert.assertTrue(fr.anyVec().isString());
  Assert.assertFalse(fr.anyVec().isCategorical());
  Assert.assertFalse(fr.anyVec().isInt());
  BufferedString tmpStr = new BufferedString();
  Assert.assertTrue(fr.anyVec().atStr(tmpStr, 3).toString().equals("4"));
  Assert.assertTrue(fr.anyVec().atStr(tmpStr, 4).toString().equals("5234234234"));
  Assert.assertTrue(fr.anyVec().atStr(tmpStr, 5).toString().equals("6"));
  fr.delete();
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:28,代码来源:ParserTestARFF.java


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