Search in sources :

Example 1 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class OptionsPanel method saveSettings.

/**
 * Save settings in config <b>cfg</b>
 *
 * @param cfg
 * @throws InvalidSettingsException
 */
public void saveSettings(final TreeEnsembleLearnerConfiguration cfg) throws InvalidSettingsException {
    cfg.setTargetColumn(m_targetColumnBox.getSelectedColumn());
    if (m_useFingerprintColumnRadio.isSelected()) {
        String fpColumn = m_fingerprintColumnBox.getSelectedColumn();
        cfg.setFingerprintColumn(fpColumn);
    // cfg.setIncludeAllColumns(false);
    } else {
        assert m_useOrdinaryColumnsRadio.isSelected();
        Set<String> incls = m_includeColumnsFilterPanel2.getIncludedNamesAsSet();
        if (incls.size() == 0) {
            throw new InvalidSettingsException("No learn columns selected");
        }
    }
    m_includeColumnsFilterPanel2.saveConfiguration(cfg.getColumnFilterConfig());
    int hiliteCount = m_enableHiliteChecker.isSelected() ? (Integer) m_hiliteCountSpinner.getValue() : -1;
    cfg.setNrHilitePatterns(hiliteCount);
    cfg.setIgnoreColumnsWithoutDomain(true);
    cfg.setSaveTargetDistributionInNodes(false);
    cfg.setSaveTargetDistributionInNodes(m_saveTargetDistributionInNodesChecker.isSelected());
    // Tree Options
    cfg.setSplitCriterion((SplitCriterion) m_splitCriterionsBox.getSelectedItem());
    cfg.setUseAverageSplitPoints(true);
    int maxLevel = m_maxLevelChecker.isSelected() ? (Integer) m_maxLevelSpinner.getValue() : TreeEnsembleLearnerConfiguration.MAX_LEVEL_INFINITE;
    cfg.setMaxLevels(maxLevel);
    int minChildNodeSize = m_minChildNodeSizeChecker.isSelected() ? (Integer) m_minChildNodeSizeSpinner.getValue() : TreeEnsembleLearnerConfiguration.MIN_CHILD_SIZE_UNDEFINED;
    cfg.setMinSizes(TreeEnsembleLearnerConfiguration.MIN_NODE_SIZE_UNDEFINED, minChildNodeSize);
    cfg.setHardCodedRootColumn(null);
    // Forest Options
    cfg.setNrModels((Integer) m_nrModelsSpinner.getValue());
    cfg.setDataFractionPerTree(1);
    cfg.setDataSelectionWithReplacement(true);
    ColumnSamplingMode cf = ColumnSamplingMode.SquareRoot;
    double columnFrac = 1.0;
    int columnAbsolute = TreeEnsembleLearnerConfiguration.DEF_COLUMN_ABSOLUTE;
    cfg.setColumnSamplingMode(cf);
    cfg.setColumnFractionLinearValue(columnFrac);
    cfg.setColumnAbsoluteValue(columnAbsolute);
    cfg.setUseDifferentAttributesAtEachNode(true);
    Long seed;
    if (m_seedChecker.isSelected()) {
        final String seedText = m_seedTextField.getText();
        try {
            seed = Long.valueOf(seedText);
        } catch (Exception e) {
            throw new InvalidSettingsException("Unable to parse seed \"" + seedText + "\"", e);
        }
    } else {
        seed = null;
    }
    cfg.setSeed(seed);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ColumnSamplingMode(org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.ColumnSamplingMode) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NotConfigurableException(org.knime.core.node.NotConfigurableException)

Example 2 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class RandomForestRegressionLearnerNodeDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    TreeEnsembleLearnerConfiguration cfg = new TreeEnsembleLearnerConfiguration(true);
    m_optionsPanel.saveSettings(cfg);
    cfg.save(settings);
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration)

Example 3 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class RandomForestClassificationLearnerNodeDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    TreeEnsembleLearnerConfiguration cfg = new TreeEnsembleLearnerConfiguration(false);
    m_optionPanel.saveSettings(cfg);
    cfg.save(settings);
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration)

Example 4 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class RandomForestClassificationLearnerNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    final DataTableSpec inSpec = specs[0];
    TreeEnsembleLearnerConfiguration cfg = new TreeEnsembleLearnerConfiguration(false);
    cfg.loadInDialog(settings, inSpec);
    m_optionPanel.loadSettingsFrom(inSpec, cfg);
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration) DataTableSpec(org.knime.core.data.DataTableSpec)

Example 5 with TreeEnsembleLearnerConfiguration

use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration in project knime-core by knime.

the class RandomForestRegressionLearnerNodeModel method loadValidatedSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
    TreeEnsembleLearnerConfiguration config = new TreeEnsembleLearnerConfiguration(true);
    config.loadInModel(settings);
    m_configuration = config;
}
Also used : TreeEnsembleLearnerConfiguration(org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration)

Aggregations

TreeEnsembleLearnerConfiguration (org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration)62 Test (org.junit.Test)29 DataMemberships (org.knime.base.node.mine.treeensemble2.data.memberships.DataMemberships)27 RootDataMemberships (org.knime.base.node.mine.treeensemble2.data.memberships.RootDataMemberships)26 SplitCandidate (org.knime.base.node.mine.treeensemble2.learner.SplitCandidate)19 RandomData (org.apache.commons.math.random.RandomData)17 BitSet (java.util.BitSet)16 DefaultDataIndexManager (org.knime.base.node.mine.treeensemble2.data.memberships.DefaultDataIndexManager)15 NominalBinarySplitCandidate (org.knime.base.node.mine.treeensemble2.learner.NominalBinarySplitCandidate)15 IDataIndexManager (org.knime.base.node.mine.treeensemble2.data.memberships.IDataIndexManager)13 NominalMultiwaySplitCandidate (org.knime.base.node.mine.treeensemble2.learner.NominalMultiwaySplitCandidate)13 TreeData (org.knime.base.node.mine.treeensemble2.data.TreeData)10 TreeNodeNominalBinaryCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeNominalBinaryCondition)10 TestDataGenerator (org.knime.base.node.mine.treeensemble2.data.TestDataGenerator)9 TreeAttributeColumnData (org.knime.base.node.mine.treeensemble2.data.TreeAttributeColumnData)8 NumericSplitCandidate (org.knime.base.node.mine.treeensemble2.learner.NumericSplitCandidate)8 TreeNodeNumericCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeNumericCondition)7 NumericMissingSplitCandidate (org.knime.base.node.mine.treeensemble2.learner.NumericMissingSplitCandidate)6 TreeNodeNominalCondition (org.knime.base.node.mine.treeensemble2.model.TreeNodeNominalCondition)6 TreeTargetNominalColumnData (org.knime.base.node.mine.treeensemble2.data.TreeTargetNominalColumnData)5