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();
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);
}
use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.ColumnSamplingMode in project knime-core by knime.
the class AdvancedOptionsPanel method saveSettings.
public void saveSettings(final GradientBoostingLearnerConfiguration cfg) throws InvalidSettingsException {
cfg.setAlpha((Double) m_alphaFractionSpinner.getValue());
cfg.setUseAverageSplitPoints(m_useAverageSplitPointsChecker.isSelected());
cfg.setUseBinaryNominalSplits(m_useBinaryNominalSplitsChecker.isSelected());
final MissingValueHandling missValHandling = (MissingValueHandling) m_missingValueHandlingComboBox.getSelectedItem();
if (missValHandling == MissingValueHandling.Surrogate && !m_useBinaryNominalSplitsChecker.isSelected()) {
throw new InvalidSettingsException("Surrogate missing value handling can only be used if binary nominal splits are enabled.");
}
cfg.setMissingValueHandling((MissingValueHandling) m_missingValueHandlingComboBox.getSelectedItem());
double dataFrac;
boolean isSamplingWithReplacement;
if (m_dataFractionPerTreeChecker.isSelected()) {
dataFrac = (Double) m_dataFractionPerTreeSpinner.getValue();
isSamplingWithReplacement = m_dataSamplingWithReplacementChecker.isSelected();
} else {
dataFrac = 1.0;
isSamplingWithReplacement = false;
}
cfg.setDataFractionPerTree(dataFrac);
cfg.setDataSelectionWithReplacement(isSamplingWithReplacement);
ColumnSamplingMode cf;
double columnFrac = 1.0;
int columnAbsolute = TreeEnsembleLearnerConfiguration.DEF_COLUMN_ABSOLUTE;
boolean isUseDifferentAttributesAtEachNode = m_columnUseDifferentSetOfAttributesForNodes.isSelected();
if (m_columnFractionNoneButton.isSelected()) {
cf = ColumnSamplingMode.None;
isUseDifferentAttributesAtEachNode = false;
} else if (m_columnFractionLinearButton.isSelected()) {
cf = ColumnSamplingMode.Linear;
columnFrac = (Double) m_columnFractionLinearTreeSpinner.getValue();
} else if (m_columnFractionAbsoluteButton.isSelected()) {
cf = ColumnSamplingMode.Absolute;
columnAbsolute = (Integer) m_columnFractionAbsoluteTreeSpinner.getValue();
} else if (m_columnFractionSqrtButton.isSelected()) {
cf = ColumnSamplingMode.SquareRoot;
} else {
throw new InvalidSettingsException("No column selection policy selected");
}
cfg.setColumnSamplingMode(cf);
cfg.setColumnFractionLinearValue(columnFrac);
cfg.setColumnAbsoluteValue(columnAbsolute);
cfg.setUseDifferentAttributesAtEachNode(isUseDifferentAttributesAtEachNode);
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);
}
use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.ColumnSamplingMode in project knime-core by knime.
the class AdvancedOptionsPanel method loadSettings.
public void loadSettings(final GradientBoostingLearnerConfiguration cfg) {
m_alphaFractionSpinner.setValue(cfg.getAlpha());
m_useAverageSplitPointsChecker.setSelected(cfg.isUseAverageSplitPoints());
m_useBinaryNominalSplitsChecker.setSelected(cfg.isUseBinaryNominalSplits());
m_missingValueHandlingComboBox.setSelectedItem(cfg.getMissingValueHandling());
double dataFrac = cfg.getDataFractionPerTree();
boolean isDataWithReplacement = cfg.isDataSelectionWithReplacement();
boolean doesSampling = dataFrac < 1.0 || isDataWithReplacement;
m_dataFractionPerTreeSpinner.setValue(dataFrac);
if (m_dataFractionPerTreeChecker.isSelected() != doesSampling) {
m_dataFractionPerTreeChecker.doClick();
}
if (isDataWithReplacement) {
m_dataSamplingWithReplacementChecker.doClick();
} else {
m_dataSamplingWithOutReplacementChecker.doClick();
}
double colFrac = cfg.getColumnFractionLinearValue();
int colAbsolute = cfg.getColumnAbsoluteValue();
boolean useDifferentAttributesAtEachNode = cfg.isUseDifferentAttributesAtEachNode();
ColumnSamplingMode columnFraction = cfg.getColumnSamplingMode();
switch(columnFraction) {
case None:
m_columnFractionNoneButton.doClick();
useDifferentAttributesAtEachNode = false;
colFrac = 1.0;
break;
case Linear:
m_columnFractionLinearButton.doClick();
break;
case Absolute:
m_columnFractionAbsoluteButton.doClick();
break;
case SquareRoot:
m_columnFractionSqrtButton.doClick();
colFrac = 1.0;
break;
}
m_columnFractionLinearTreeSpinner.setValue(colFrac);
m_columnFractionAbsoluteTreeSpinner.setValue(colAbsolute);
if (useDifferentAttributesAtEachNode) {
m_columnUseDifferentSetOfAttributesForNodes.doClick();
} else {
m_columnUseSameSetOfAttributesForNodes.doClick();
}
Long seed = cfg.getSeed();
if (m_seedChecker.isSelected() != (seed != null)) {
m_seedChecker.doClick();
}
m_seedTextField.setText(Long.toString(seed != null ? seed : System.currentTimeMillis()));
}
use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.ColumnSamplingMode in project knime-core by knime.
the class EnsembleOptionsPanel method loadSettings.
/**
* Load settings from config <b>cfg</b>
*
* @param cfg
*/
public void loadSettings(final TreeEnsembleLearnerConfiguration cfg) {
m_nrModelsSpinner.setValue(cfg.getNrModels());
double dataFrac = cfg.getDataFractionPerTree();
boolean isDataWithReplacement = cfg.isDataSelectionWithReplacement();
boolean isEqualSizeSampling = cfg.getRowSamplingMode() == RowSamplingMode.EqualSize;
boolean doesSampling = dataFrac < 1.0 || isDataWithReplacement || isEqualSizeSampling;
m_dataFractionPerTreeSpinner.setValue(dataFrac);
if (m_dataFractionPerTreeChecker.isSelected() != doesSampling) {
m_dataFractionPerTreeChecker.doClick();
}
if (isDataWithReplacement) {
m_dataSamplingWithReplacementChecker.doClick();
} else {
m_dataSamplingWithOutReplacementChecker.doClick();
}
m_dataSamplingModeComboBox.setSelectedItem(cfg.getRowSamplingMode());
double colFrac = cfg.getColumnFractionLinearValue();
int colAbsolute = cfg.getColumnAbsoluteValue();
boolean useDifferentAttributesAtEachNode = cfg.isUseDifferentAttributesAtEachNode();
ColumnSamplingMode columnFraction = cfg.getColumnSamplingMode();
switch(columnFraction) {
case None:
m_columnFractionNoneButton.doClick();
useDifferentAttributesAtEachNode = false;
colFrac = 1.0;
break;
case Linear:
m_columnFractionLinearButton.doClick();
break;
case Absolute:
m_columnFractionAbsoluteButton.doClick();
break;
case SquareRoot:
m_columnFractionSqrtButton.doClick();
colFrac = 1.0;
break;
}
m_columnFractionLinearTreeSpinner.setValue(colFrac);
m_columnFractionAbsoluteTreeSpinner.setValue(colAbsolute);
if (useDifferentAttributesAtEachNode) {
m_columnUseDifferentSetOfAttributesForNodes.doClick();
} else {
m_columnUseSameSetOfAttributesForNodes.doClick();
}
Long seed = cfg.getSeed();
if (m_seedChecker.isSelected() != (seed != null)) {
m_seedChecker.doClick();
}
m_seedTextField.setText(Long.toString(seed != null ? seed : System.currentTimeMillis()));
}
use of org.knime.base.node.mine.treeensemble2.node.learner.TreeEnsembleLearnerConfiguration.ColumnSamplingMode in project knime-core by knime.
the class EnsembleOptionsPanel method saveSettings.
/**
* Save settings to config <b>cfg</b>
*
* @param cfg
* @throws InvalidSettingsException
*/
public void saveSettings(final TreeEnsembleLearnerConfiguration cfg) throws InvalidSettingsException {
cfg.setNrModels((Integer) m_nrModelsSpinner.getValue());
double dataFrac;
boolean isSamplingWithReplacement;
if (m_dataFractionPerTreeChecker.isSelected()) {
dataFrac = (Double) m_dataFractionPerTreeSpinner.getValue();
isSamplingWithReplacement = m_dataSamplingWithReplacementChecker.isSelected();
} else {
dataFrac = 1.0;
isSamplingWithReplacement = false;
}
cfg.setDataFractionPerTree(dataFrac);
cfg.setDataSelectionWithReplacement(isSamplingWithReplacement);
cfg.setRowSamplingMode((RowSamplingMode) m_dataSamplingModeComboBox.getSelectedItem());
ColumnSamplingMode cf;
double columnFrac = 1.0;
int columnAbsolute = TreeEnsembleLearnerConfiguration.DEF_COLUMN_ABSOLUTE;
boolean isUseDifferentAttributesAtEachNode = m_columnUseDifferentSetOfAttributesForNodes.isSelected();
if (m_columnFractionNoneButton.isSelected()) {
cf = ColumnSamplingMode.None;
isUseDifferentAttributesAtEachNode = false;
} else if (m_columnFractionLinearButton.isSelected()) {
cf = ColumnSamplingMode.Linear;
columnFrac = (Double) m_columnFractionLinearTreeSpinner.getValue();
} else if (m_columnFractionAbsoluteButton.isSelected()) {
cf = ColumnSamplingMode.Absolute;
columnAbsolute = (Integer) m_columnFractionAbsoluteTreeSpinner.getValue();
} else if (m_columnFractionSqrtButton.isSelected()) {
cf = ColumnSamplingMode.SquareRoot;
} else {
throw new InvalidSettingsException("No column selection policy selected");
}
cfg.setColumnSamplingMode(cf);
cfg.setColumnFractionLinearValue(columnFrac);
cfg.setColumnAbsoluteValue(columnAbsolute);
cfg.setUseDifferentAttributesAtEachNode(isUseDifferentAttributesAtEachNode);
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);
}
Aggregations