Search in sources :

Example 1 with EnsembleStatistic

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() };
}
Also used : TreeEnsembleModelPortObject(org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModelPortObject) TreeStatistic(org.knime.base.node.mine.treeensemble2.statistics.TreeStatistic) TreeEnsembleModel(org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModel) DataContainer(org.knime.core.data.container.DataContainer) DoubleCell(org.knime.core.data.def.DoubleCell) DataCell(org.knime.core.data.DataCell) EnsembleStatistic(org.knime.base.node.mine.treeensemble2.statistics.EnsembleStatistic) DefaultRow(org.knime.core.data.def.DefaultRow) TreeEnsembleModelPortObject(org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModelPortObject) PortObject(org.knime.core.node.port.PortObject) IntCell(org.knime.core.data.def.IntCell)

Example 2 with EnsembleStatistic

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());
}
Also used : EnsembleStatistic(org.knime.base.node.mine.treeensemble2.statistics.EnsembleStatistic)

Aggregations

EnsembleStatistic (org.knime.base.node.mine.treeensemble2.statistics.EnsembleStatistic)2 TreeEnsembleModel (org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModel)1 TreeEnsembleModelPortObject (org.knime.base.node.mine.treeensemble2.model.TreeEnsembleModelPortObject)1 TreeStatistic (org.knime.base.node.mine.treeensemble2.statistics.TreeStatistic)1 DataCell (org.knime.core.data.DataCell)1 DataContainer (org.knime.core.data.container.DataContainer)1 DefaultRow (org.knime.core.data.def.DefaultRow)1 DoubleCell (org.knime.core.data.def.DoubleCell)1 IntCell (org.knime.core.data.def.IntCell)1 PortObject (org.knime.core.node.port.PortObject)1