water.fvec.Frame.toTwoDimTable()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中water.fvec.Frame.toTwoDimTable()方法的一些代码示例,展示了Frame.toTwoDimTable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frame.toTwoDimTable()方法的具体详情如下:
包路径:water.fvec.Frame
类名称:Frame
方法名:toTwoDimTable

Frame.toTwoDimTable介绍

暂无

代码示例

代码示例来源:origin: h2oai/h2o-3

private void printOutFrameAsTable(Frame fr, boolean full, boolean rollups) {
 TwoDimTable twoDimTable = fr.toTwoDimTable(0, 10000, rollups);
 System.out.println(twoDimTable.toString(2, full));
}

代码示例来源:origin: h2oai/h2o-3

private void printOutFrameAsTable(Frame fr) {
 TwoDimTable twoDimTable = fr.toTwoDimTable();
 System.out.println(twoDimTable.toString(2, false));
}

代码示例来源:origin: h2oai/h2o-3

private void printOutFrameAsTable(Frame fr) {
 TwoDimTable twoDimTable = fr.toTwoDimTable();
 System.out.println(twoDimTable.toString(2, false));
}

代码示例来源:origin: h2oai/h2o-3

private void printOutFrameAsTable(Frame fr, boolean full, boolean rollups) {
 TwoDimTable twoDimTable = fr.toTwoDimTable(0, 10000, rollups);
 System.out.println(twoDimTable.toString(2, full));
}

代码示例来源:origin: h2oai/h2o-3

private void printOutFrameAsTable(Frame fr) {
 TwoDimTable twoDimTable = fr.toTwoDimTable();
 System.out.println(twoDimTable.toString(2, false));
}

代码示例来源:origin: h2oai/h2o-3

private void printOutColumnsMeta(Frame fr) {
 for (String header : fr.toTwoDimTable().getColHeaders()) {
  String type = fr.vec(header).get_type_str();
  int cardinality = fr.vec(header).cardinality();
  System.out.println(header + " - " + type + String.format("; Cardinality = %d", cardinality));
 }
}
private void encodingMapCleanUp(Map<String, Frame> encodingMap) {

代码示例来源:origin: h2oai/h2o-3

private void printOutColumnsMeta(Frame fr) {
  for (String header : fr.toTwoDimTable().getColHeaders()) {
   String type = fr.vec(header).get_type_str();
   int cardinality = fr.vec(header).cardinality();
   System.out.println(header + " - " + type + String.format("; Cardinality = %d", cardinality));

  }
 }
}

代码示例来源:origin: h2oai/h2o-3

private void printOutColumnsMeta(Frame fr) {
  for (String header : fr.toTwoDimTable().getColHeaders()) {
   String type = fr.vec(header).get_type_str();
   int cardinality = fr.vec(header).cardinality();
   System.out.println(header + " - " + type + String.format("; Cardinality = %d", cardinality));

  }
 }
}

代码示例来源:origin: h2oai/h2o-3

public void testAggregator(int max) {
 CreateFrame cf = new CreateFrame();
 cf.rows = 100000;
 cf.cols = 2;
 cf.categorical_fraction = 0.1;
 cf.integer_fraction = 0.3;
 cf.real_range = 100;
 cf.integer_range = 100;
 cf.seed = 1234;
 Frame frame = cf.execImpl().get();
 AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
 parms._train = frame._key;
 parms._target_num_exemplars = max;
 long start = System.currentTimeMillis();
 AggregatorModel agg = new Aggregator(parms).trainModel().get();
 System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start)/1000. + " seconds");
 agg.checkConsistency();
 Frame output = agg._output._output_frame.get();
 System.out.println(output.toTwoDimTable(0,10));
 frame.delete();
 checkNumExemplars(agg);
 output.remove();
 agg.remove();
}

代码示例来源:origin: h2oai/h2o-3

agg.checkConsistency();
Frame output = agg._output._output_frame.get();
System.out.println(output.toTwoDimTable(0, (int)output.numRows()));
Log.info("Number of exemplars: " + agg._exemplars.length);
Assert.assertTrue(agg._exemplars.length==17);

代码示例来源:origin: h2oai/h2o-3

agg.checkConsistency();
Frame output = agg._output._output_frame.get();
System.out.println(output.toTwoDimTable(0, (int)output.numRows()));
Log.info("Number of exemplars: " + agg._exemplars.length);
Assert.assertTrue(agg._exemplars.length==7);

代码示例来源:origin: h2oai/h2o-3

@Test public void testAggregatorEigen() {
 CreateFrame cf = new CreateFrame();
 cf.rows = 1000;
 cf.cols = 10;
 cf.categorical_fraction = 0.6;
 cf.integer_fraction = 0.0;
 cf.binary_fraction = 0.0;
 cf.real_range = 100;
 cf.integer_range = 100;
 cf.missing_fraction = 0;
 cf.factors = 5;
 cf.seed = 1234;
 Frame frame = cf.execImpl().get();
 AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
 parms._train = frame._key;
 parms._categorical_encoding = Model.Parameters.CategoricalEncodingScheme.Eigen;
 long start = System.currentTimeMillis();
 AggregatorModel agg = new Aggregator(parms).trainModel().get();  // 0.905
 System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start)/1000. + " seconds");
 agg.checkConsistency();
 Frame output = agg._output._output_frame.get();
 System.out.println(output.toTwoDimTable(0,10));
 Log.info("Number of exemplars: " + agg._exemplars.length);
 output.remove();
 frame.remove();
 agg.remove();
}

代码示例来源:origin: h2oai/h2o-3

@Test public void testAggregatorEigenHighCardinality() {
 CreateFrame cf = new CreateFrame();
 cf.rows = 10000;
 cf.cols = 10;
 cf.categorical_fraction = 0.6;
 cf.integer_fraction = 0.0;
 cf.binary_fraction = 0.0;
 cf.real_range = 100;
 cf.integer_range = 100;
 cf.missing_fraction = 0;
 cf.factors = 1000; //more than 100 - expect to see 'other' in the aggregated frame
 cf.seed = 1234;
 Frame frame = cf.execImpl().get();
 AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
 parms._train = frame._key;
 parms._categorical_encoding = Model.Parameters.CategoricalEncodingScheme.Eigen;
 long start = System.currentTimeMillis();
 AggregatorModel agg = new Aggregator(parms).trainModel().get();  // 0.905
 System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start)/1000. + " seconds");
 agg.checkConsistency();
 Frame output = agg._output._output_frame.get();
 System.out.println(output.toTwoDimTable(0,10));
 Log.info("Number of exemplars: " + agg._exemplars.length);
 output.remove();
 frame.remove();
 agg.remove();
}

代码示例来源:origin: h2oai/h2o-3

@Test public void testAggregatorBinary() {
 CreateFrame cf = new CreateFrame();
 cf.rows = 1000;
 cf.cols = 10;
 cf.categorical_fraction = 0.6;
 cf.integer_fraction = 0.0;
 cf.binary_fraction = 0.0;
 cf.real_range = 100;
 cf.integer_range = 100;
 cf.missing_fraction = 0.1;
 cf.factors = 5;
 cf.seed = 1234;
 Frame frame = cf.execImpl().get();
 AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
 parms._train = frame._key;
 parms._transform = DataInfo.TransformType.NORMALIZE;
 parms._categorical_encoding = Model.Parameters.CategoricalEncodingScheme.Binary;
 long start = System.currentTimeMillis();
 AggregatorModel agg = new Aggregator(parms).trainModel().get();  // 0.905
 System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start)/1000. + " seconds");
 agg.checkConsistency();
 Frame output = agg._output._output_frame.get();
 System.out.println(output.toTwoDimTable(0,10));
 Log.info("Number of exemplars: " + agg._exemplars.length);
 Assert.assertTrue(agg._exemplars.length==1000);
 output.remove();
 frame.remove();
 agg.remove();
}

代码示例来源:origin: h2oai/h2o-3

@Test public void testAggregatorEigenHighCardinalityEnum() {
 CreateFrame cf = new CreateFrame();
 cf.rows = 10000;
 cf.cols = 10;
 cf.categorical_fraction = 0.6;
 cf.integer_fraction = 0.0;
 cf.binary_fraction = 0.0;
 cf.real_range = 100;
 cf.integer_range = 100;
 cf.missing_fraction = 0;
 cf.factors = 1000; //more than 100 - expect to see 'other' in the aggregated frame
 cf.seed = 1234;
 Frame frame = cf.execImpl().get();
 AggregatorModel.AggregatorParameters parms = new AggregatorModel.AggregatorParameters();
 parms._train = frame._key;
 parms._categorical_encoding = Model.Parameters.CategoricalEncodingScheme.Enum;
 long start = System.currentTimeMillis();
 AggregatorModel agg = new Aggregator(parms).trainModel().get();  // 0.905
 System.out.println("AggregatorModel finished in: " + (System.currentTimeMillis() - start)/1000. + " seconds");
 agg.checkConsistency();
 Frame output = agg._output._output_frame.get();
 System.out.println(output.toTwoDimTable(0, (int)output.numRows()));
 Log.info("Number of exemplars: " + agg._exemplars.length);
 output.remove();
 frame.remove();
 agg.remove();
}

代码示例来源:origin: h2oai/h2o-3

agg.checkConsistency();
Frame output = agg._output._output_frame.get();
System.out.println(output.toTwoDimTable(0,10));
checkNumExemplars(agg);
output.remove();

代码示例来源:origin: h2oai/h2o-3

@Test public void testNACategorical() {
 String xy = ",0\nA,0\nB,0\nA,0\nD,-10\n,0";
 Key tr = Key.make("train");
 Frame df = ParseDataset.parse(tr, makeByteVec(Key.make("xy"), xy));
 GBMModel.GBMParameters parms = new GBMModel.GBMParameters();
 parms._train = tr;
 parms._response_column = "C2";
 parms._min_rows = 1;
 parms._learn_rate = 1;
 parms._ntrees = 1;
 GBM job = new GBM(parms);
 GBMModel gbm = job.trainModel().get();
 Log.info(df.toTwoDimTable());
 Frame preds = gbm.score(df);
 Log.info(preds.toTwoDimTable());
 Assert.assertTrue(gbm.testJavaScoring(df,preds,1e-15));
 Assert.assertTrue(Math.abs(preds.vec(0).at(0) - 0) < 1e-6);
 Assert.assertTrue(Math.abs(preds.vec(0).at(1) - 0) < 1e-6);
 Assert.assertTrue(Math.abs(preds.vec(0).at(2) - 0) < 1e-6);
 Assert.assertTrue(Math.abs(preds.vec(0).at(3) - 0) < 1e-6);
 Assert.assertTrue(Math.abs(preds.vec(0).at(4) - -10) < 1e-6);
 Assert.assertTrue(Math.abs(preds.vec(0).at(5) - 0) < 1e-6);
 preds.remove();
 gbm.remove();
 df.remove();
}

代码示例来源:origin: h2oai/h2o-3

@Test
public void targetEncoderGetOutOfFoldDataTest() {
 fr = new TestFrameBuilder()
     .withName("testFrame")
     .withColNames("ColA", "ColB")
     .withVecTypes(Vec.T_NUM, Vec.T_NUM)
     .withDataForCol(0, ard(5, 6, 7, 9))
     .withDataForCol(1, ard(1, 2, 3, 1))
     .build();
 String[] teColumns = {""};
 TargetEncoder tec = new TargetEncoder(teColumns);
 Frame outOfFoldData = tec.getOutOfFoldData(fr, "ColB", 1);
 TwoDimTable twoDimTable = outOfFoldData.toTwoDimTable();
 assertEquals(outOfFoldData.numRows(), 2);
 assertEquals(6L, twoDimTable.get(5, 0));
 assertEquals(7L, twoDimTable.get(6, 0));
 Frame outOfFoldData2 = tec.getOutOfFoldData(fr, "ColB", 2);
 TwoDimTable twoDimTable2 = outOfFoldData2.toTwoDimTable();
 assertEquals(5L, twoDimTable2.get(5, 0));
 assertEquals(7L, twoDimTable2.get(6, 0));
 assertEquals(9L, twoDimTable2.get(7, 0));
 outOfFoldData.delete();
 outOfFoldData2.delete();
}

代码示例来源:origin: h2oai/h2o-3

@Test
public void targetEncoderKFoldHoldoutApplyingWithCustomNoiseTest() {
 String teColumnName = "ColA";
 String targetColumnName = "ColC";
 String foldColumnName = "fold_column";
 fr = new TestFrameBuilder()
     .withName("testFrame")
     .withColNames(teColumnName, "ColB", targetColumnName, foldColumnName)
     .withVecTypes(Vec.T_CAT, Vec.T_NUM, Vec.T_CAT, Vec.T_NUM)
     .withDataForCol(0, ar("a", "b", "b", "b", "a"))
     .withDataForCol(1, ard(1, 1, 4, 7, 4))
     .withDataForCol(2, ar("2", "6", "6", "6", "6"))
     .withDataForCol(3, ar(1, 2, 2, 3, 2))
     .build();
 String[] teColumns = {teColumnName};
 TargetEncoder tec = new TargetEncoder(teColumns);
 Map<String, Frame> targetEncodingMap = tec.prepareEncodingMap(fr, targetColumnName, foldColumnName);
 Frame resultWithEncoding = tec.applyTargetEncoding(fr, targetColumnName, targetEncodingMap, TargetEncoder.DataLeakageHandlingStrategy.KFold, foldColumnName, false, 0.02, false, 1234);
 TwoDimTable resultTable = resultWithEncoding.toTwoDimTable();
 System.out.println("Result table" + resultTable.toString());
 Vec expected = vec(1, 0, 1, 1, 1);
 assertVecEquals(expected, resultWithEncoding.vec(4), 2e-2); // TODO we do not check here actually that we have noise more then default 0.01. We need to check that sometimes we get 0.01 < delta < 0.02
 expected.remove();
 encodingMapCleanUp(targetEncodingMap);
 resultWithEncoding.delete();
}

代码示例来源:origin: h2oai/h2o-3

Log.info(preds.toTwoDimTable());
if (preds2!=null)
 Log.info(preds2.toTwoDimTable());
if (preds3!=null)
 Log.info(preds3.toTwoDimTable());

相关文章