use of org.knime.base.node.mine.treeensemble2.statistics.EnsembleStatistic in project knime-core by knime.
the class TreeEnsembleStatisticsNodeModel method execute.
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
TreeEnsembleModel treeEnsemble = ((TreeEnsembleModelPortObject) inObjects[0]).getEnsembleModel();
EnsembleStatistic ensembleStats = new EnsembleStatistic(treeEnsemble);
DataContainer containerEnsembleStats = exec.createDataContainer(createEnsembleStatsSpec());
DataCell[] cells = new DataCell[7];
cells[0] = new IntCell(treeEnsemble.getNrModels());
cells[1] = new IntCell(ensembleStats.getMinLevel());
cells[2] = new IntCell(ensembleStats.getMaxLevel());
cells[3] = new DoubleCell(ensembleStats.getAvgLevel());
cells[4] = new IntCell(ensembleStats.getMinNumNodes());
cells[5] = new IntCell(ensembleStats.getMaxNumNodes());
cells[6] = new DoubleCell(ensembleStats.getAvgNumNodes());
containerEnsembleStats.addRowToTable(new DefaultRow(RowKey.createRowKey(0L), cells));
containerEnsembleStats.close();
DataContainer containerTreeStats = exec.createDataContainer(createTreeStatsSpec());
for (int i = 0; i < treeEnsemble.getNrModels(); i++) {
DataCell[] treeCells = new DataCell[2];
TreeStatistic treeStat = ensembleStats.getTreeStatistic(i);
treeCells[0] = new IntCell(treeStat.getNumLevels());
treeCells[1] = new IntCell(treeStat.getNumNodes());
containerTreeStats.addRowToTable(new DefaultRow(RowKey.createRowKey((long) i), treeCells));
}
containerTreeStats.close();
return new PortObject[] { (PortObject) containerEnsembleStats.getTable(), (PortObject) containerTreeStats.getTable() };
}
use of org.knime.base.node.mine.treeensemble2.statistics.EnsembleStatistic in project knime-core by knime.
the class RandomForestClassificationLearnerNodeModel method printEnsembleStatistics.
private void printEnsembleStatistics(final TreeEnsembleModel ensembleModel) {
EnsembleStatistic stat = new EnsembleStatistic(ensembleModel);
System.out.println("minLevel: " + stat.getMinLevel());
System.out.println("maxLevel: " + stat.getMaxLevel());
System.out.println("avgLevel: " + stat.getAvgLevel());
System.out.println("minNumNodes: " + stat.getMinNumNodes());
System.out.println("maxNumNodes: " + stat.getMaxNumNodes());
System.out.println("avgNumNodes: " + stat.getAvgNumNodes());
System.out.println("avgNumSurrogates: " + stat.getAvgNumSurrogates());
}
Aggregations