Search in sources :

Example 1 with SplitCriterion

use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.SplitCriterion 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)

Aggregations

ColumnSamplingMode (org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.ColumnSamplingMode)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 NotConfigurableException (org.knime.core.node.NotConfigurableException)1