Search in sources :

Example 6 with ColumnSamplingMode

use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.ColumnSamplingMode 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();
        // boolean useAll = m_includeColumnsFilterPanel.isKeepAllSelected();
        // if (useAll) {
        // cfg.setIncludeAllColumns(true);
        // } else {
        // cfg.setIncludeAllColumns(false);
        // Set<String> incls = m_includeColumnsFilterPanel.getIncludedColumnSet();
        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(m_ignoreColumnsWithoutDomainChecker.isSelected());
    // cfg.setSaveTargetDistributionInNodes(false);
    // cfg.setIgnoreColumnsWithoutDomain(m_ignoreColumnsWithoutDomainChecker.isSelected());
    // cfg.setSaveTargetDistributionInNodes(m_saveTargetDistributionInNodesChecker.isSelected());
    // Tree Options
    cfg.setSplitCriterion(SplitCriterion.Gini);
    // cfg.setUseAverageSplitPoints(m_useAverageSplitPointsChecker.isSelected());
    cfg.setUseBinaryNominalSplits(m_useBinaryNominalSplitsCheckBox.isSelected());
    final MissingValueHandling missValHandling = (MissingValueHandling) m_missingValueHandlingComboBox.getSelectedItem();
    if (missValHandling == MissingValueHandling.Surrogate && !m_useBinaryNominalSplitsCheckBox.isSelected()) {
        throw new InvalidSettingsException("Surrogate missing value handling only works if binary nominal splits are enabled");
    }
    cfg.setMissingValueHandling(missValHandling);
    cfg.setUseAverageSplitPoints(true);
    int maxLevel = m_maxLevelChecker.isSelected() ? (Integer) m_maxLevelSpinner.getValue() : TreeEnsembleLearnerConfiguration.MAX_LEVEL_INFINITE;
    cfg.setMaxLevels(maxLevel);
    int minNodeSize = m_minNodeSizeChecker.isSelected() ? (Integer) m_minNodeSizeSpinner.getValue() : TreeEnsembleLearnerConfiguration.MIN_NODE_SIZE_UNDEFINED;
    int minChildNodeSize = m_minChildNodeSizeChecker.isSelected() ? (Integer) m_minChildNodeSizeSpinner.getValue() : TreeEnsembleLearnerConfiguration.MIN_CHILD_SIZE_UNDEFINED;
    cfg.setMinSizes(minNodeSize, minChildNodeSize);
    cfg.setHardCodedRootColumn(null);
    // Forest Options
    ColumnSamplingMode cf = ColumnSamplingMode.None;
    double columnFrac = 1.0;
    int columnAbsolute = TreeEnsembleLearnerConfiguration.DEF_COLUMN_ABSOLUTE;
    cfg.setColumnSamplingMode(cf);
    cfg.setColumnFractionLinearValue(columnFrac);
    cfg.setColumnAbsoluteValue(columnAbsolute);
    cfg.setUseDifferentAttributesAtEachNode(false);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) MissingValueHandling(org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.MissingValueHandling) ColumnSamplingMode(org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.ColumnSamplingMode)

Aggregations

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