use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class ColumnToGrid2NodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
ColumnToGrid2Configuration config = new ColumnToGrid2Configuration();
config.loadSettings(settings, specs[0]);
DataColumnSpecFilterConfiguration filterConfig = config.getFilterConfiguration();
m_filterPanel.loadConfiguration(filterConfig, specs[0]);
m_gridColSpinner.setValue(config.getColCount());
String groupCol = config.getGroupColumn();
if (m_enableGroupingChecker.isSelected() != (groupCol != null)) {
m_enableGroupingChecker.doClick();
}
try {
m_groupColumnCombo.update(specs[0], groupCol);
} catch (NotConfigurableException nce) {
// ignore
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class TreeOptionsPanel method newTargetSelected.
/**
*/
private void newTargetSelected() {
DataTableSpec filtered = m_attributePanel.getCurrentAttributeSpec();
String prevSelected = m_hardCodedRootColumnBox.getSelectedColumn();
try {
m_hardCodedRootColumnBox.update(filtered, prevSelected);
} catch (NotConfigurableException nfe) {
LOGGER.coding("Unable to update column list upon target " + "selection change", nfe);
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class TreeEnsembleLearnerConfiguration method loadInDialog.
/**
* Loads the settings. Intended for the use in the NodeDialog
*
* @param settings
* @param inSpec
* @throws NotConfigurableException
*/
public void loadInDialog(final NodeSettingsRO settings, final DataTableSpec inSpec) throws NotConfigurableException {
String defTargetColumn = null;
String defFingerprintColumn = null;
boolean hasAttributeColumns = false;
// guess defaults:
// traverse columns backwards; assign last (i.e. first-seen) appropriate
// column as target, use any subsequent as valid learning attribute
Class<? extends DataValue> targetClass = getRequiredTargetClass();
for (int i = inSpec.getNumColumns() - 1; i >= 0; i--) {
DataColumnSpec colSpec = inSpec.getColumnSpec(i);
DataType colType = colSpec.getType();
String colName = colSpec.getName();
if (colType.isCompatible(BitVectorValue.class) || colType.isCompatible(ByteVectorValue.class) || colType.isCompatible(DoubleVectorValue.class)) {
defFingerprintColumn = colName;
} else if (colType.isCompatible(NominalValue.class) || colType.isCompatible(DoubleValue.class)) {
if (colType.isCompatible(targetClass)) {
if (defTargetColumn == null) {
// first categorical column
defTargetColumn = colName;
} else {
hasAttributeColumns = true;
}
} else {
hasAttributeColumns = true;
}
}
}
if (defTargetColumn == null) {
throw new NotConfigurableException("No possible target in input (node not connected?) -- unable to configure.");
}
if (!hasAttributeColumns && defFingerprintColumn == null) {
throw new NotConfigurableException("No appropriate learning column " + "in input (need to have at least one additional " + "numeric/categorical column, fingerprint data or byte or double vector data)");
}
// assign fields:
m_targetColumn = settings.getString(KEY_TARGET_COLUMN, defTargetColumn);
DataColumnSpec targetColSpec = inSpec.getColumnSpec(m_targetColumn);
if (targetColSpec == null || !targetColSpec.getType().isCompatible(targetClass)) {
m_targetColumn = defTargetColumn;
}
String hardCodedRootColumn = settings.getString(KEY_ROOT_COLUMN, null);
if (inSpec.getColumnSpec(hardCodedRootColumn) == null) {
m_hardCodedRootColumn = null;
} else {
m_hardCodedRootColumn = hardCodedRootColumn;
}
m_fingerprintColumn = settings.getString(KEY_FINGERPRINT_COLUMN, defFingerprintColumn);
if (m_fingerprintColumn == null) {
// null in node settings - leave it
} else {
DataColumnSpec fpColSpec = inSpec.getColumnSpec(m_fingerprintColumn);
if (fpColSpec == null || !fpColSpec.getType().isCompatible(BitVectorValue.class)) {
m_fingerprintColumn = defFingerprintColumn;
}
}
// m_includeColumns = settings.getStringArray(KEY_INCLUDE_COLUMNS, (String[])null);
// m_includeAllColumns = settings.getBoolean(KEY_INCLUDE_ALL_COLUMNS, true);
m_columnFilterConfig.loadConfigurationInDialog(settings, inSpec);
Long defSeed = System.currentTimeMillis();
String seedS = settings.getString(KEY_SEED, Long.toString(defSeed));
Long seed;
if (seedS == null) {
seed = null;
} else {
try {
seed = Long.parseLong(seedS);
} catch (NumberFormatException nfe) {
seed = m_seed;
}
}
m_seed = seed;
m_maxLevels = settings.getInt(KEY_MAX_LEVELS, DEF_MAX_LEVEL);
if (m_maxLevels != MAX_LEVEL_INFINITE && m_maxLevels <= 0) {
m_maxLevels = DEF_MAX_LEVEL;
}
int minNodeSize = settings.getInt(KEY_MIN_NODE_SIZE, MIN_NODE_SIZE_UNDEFINED);
int minChildSize = settings.getInt(KEY_MIN_CHILD_SIZE, MIN_CHILD_SIZE_UNDEFINED);
try {
setMinSizes(minNodeSize, minChildSize);
} catch (InvalidSettingsException e) {
m_minNodeSize = MIN_NODE_SIZE_UNDEFINED;
m_minChildSize = MIN_CHILD_SIZE_UNDEFINED;
}
m_dataFractionPerTree = settings.getDouble(KEY_DATA_FRACTION, DEF_DATA_FRACTION);
if (m_dataFractionPerTree <= 0.0 || m_dataFractionPerTree > 1.0) {
m_dataFractionPerTree = DEF_DATA_FRACTION;
}
m_columnAbsoluteValue = settings.getInt(KEY_COLUMN_ABSOLUTE, DEF_COLUMN_ABSOLUTE);
if (m_columnAbsoluteValue <= 0) {
m_columnAbsoluteValue = DEF_COLUMN_ABSOLUTE;
}
m_isDataSelectionWithReplacement = settings.getBoolean(KEY_IS_DATA_SELECTION_WITH_REPLACEMENT, true);
ColumnSamplingMode defColSamplingMode = DEF_COLUMN_SAMPLING_MODE;
ColumnSamplingMode colSamplingMode = defColSamplingMode;
String colSamplingModeS = settings.getString(KEY_COLUMN_SAMPLING_MODE, null);
if (colSamplingModeS == null) {
colSamplingMode = defColSamplingMode;
} else {
try {
colSamplingMode = ColumnSamplingMode.valueOf(colSamplingModeS);
} catch (Exception e) {
colSamplingMode = defColSamplingMode;
}
}
double colFracLinValue;
switch(colSamplingMode) {
case Linear:
colFracLinValue = settings.getDouble(KEY_COLUMN_FRACTION_LINEAR, DEF_COLUMN_FRACTION);
if (colFracLinValue <= 0.0 || colFracLinValue > 1.0) {
colFracLinValue = DEF_COLUMN_FRACTION;
}
break;
default:
colFracLinValue = DEF_COLUMN_FRACTION;
}
m_columnSamplingMode = colSamplingMode;
m_columnFractionLinearValue = colFracLinValue;
m_isUseDifferentAttributesAtEachNode = settings.getBoolean(KEY_IS_USE_DIFFERENT_ATTRIBUTES_AT_EACH_NODE, true);
m_nrModels = settings.getInt(KEY_NR_MODELS, DEF_NR_MODELS);
if (m_nrModels <= 0) {
m_nrModels = DEF_NR_MODELS;
}
SplitCriterion defSplitCriterion = SplitCriterion.InformationGainRatio;
String splitCriterionS = settings.getString(KEY_SPLIT_CRITERION, defSplitCriterion.name());
SplitCriterion splitCriterion;
if (splitCriterionS == null) {
splitCriterion = defSplitCriterion;
} else {
try {
splitCriterion = SplitCriterion.valueOf(splitCriterionS);
} catch (Exception e) {
splitCriterion = defSplitCriterion;
}
}
m_splitCriterion = splitCriterion;
m_useAverageSplitPoints = settings.getBoolean(KEY_USE_AVERAGE_SPLIT_POINTS, DEF_AVERAGE_SPLIT_POINTS);
m_useBinaryNominalSplits = settings.getBoolean(KEY_USE_BINARY_NOMINAL_SPLITS, DEF_BINARY_NOMINAL_SPLITS);
String missingValueHandlingS = settings.getString(KEY_MISSING_VALUE_HANDLING, DEF_MISSING_VALUE_HANDLING.name());
MissingValueHandling missingValueHandling;
if (missingValueHandlingS == null) {
missingValueHandling = DEF_MISSING_VALUE_HANDLING;
} else {
try {
missingValueHandling = MissingValueHandling.valueOf(missingValueHandlingS);
} catch (Exception e) {
missingValueHandling = DEF_MISSING_VALUE_HANDLING;
}
}
m_missingValueHandling = missingValueHandling;
FilterResult filterResult = m_columnFilterConfig.applyTo(inSpec);
if (m_fingerprintColumn != null) {
// use fingerprint data, OK
} else if (filterResult.getIncludes().length > 0) {
// some attributes set, OK
// } else if (m_includeAllColumns) {
// use all appropriate columns, OK
} else if (defFingerprintColumn != null) {
// no valid columns but fingerprint column found - use it
m_fingerprintColumn = defFingerprintColumn;
// } else {
// m_includeAllColumns = true;
}
m_ignoreColumnsWithoutDomain = settings.getBoolean(KEY_IGNORE_COLUMNS_WITHOUT_DOMAIN, true);
m_nrHilitePatterns = settings.getInt(KEY_NR_HILITE_PATTERNS, -1);
m_saveTargetDistributionInNodes = settings.getBoolean(KEY_SAVE_TARGET_DISTRIBUTION_IN_NODES, DEF_SAVE_TARGET_DISTRIBUTION_IN_NODES);
setRowSamplingMode(RowSamplingMode.valueOf(settings.getString(KEY_ROW_SAMPLING_MODE, DEF_ROW_SAMPLING_MODE.name())));
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class DialogComponentColumnNameSelection method updateComponent.
/**
* {@inheritDoc}
*/
@Override
protected void updateComponent() {
String classCol = ((SettingsModelString) getModel()).getStringValue();
if ((classCol == null) || (classCol.length() == 0)) {
classCol = "** Unknown column **";
}
try {
final DataTableSpec spec = (DataTableSpec) getLastTableSpec(m_specIndex);
boolean useRowID = getModel() instanceof SettingsModelColumnName && ((SettingsModelColumnName) getModel()).useRowID();
if (spec != null) {
m_chooser.update(spec, classCol, useRowID);
} else if (!m_isRequired) {
m_chooser.update(new DataTableSpec(), classCol, useRowID);
}
} catch (final NotConfigurableException e1) {
// this exception shouldn't fly.
assert false;
}
// update the enable status
setEnabledComponents(getModel().isEnabled());
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class MovingAggregationNodeDialog method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
if (specs == null || specs.length != 1) {
return;
}
m_winLength.loadSettingsFrom(settings, specs);
m_windowType.loadSettingsFrom(settings, specs);
m_cumulativeComp.loadSettingsFrom(settings, specs);
m_handleMissings.loadSettingsFrom(settings, specs);
m_removeRetainedCols.loadSettingsFrom(settings, specs);
m_removeAggrCols.loadSettingsFrom(settings, specs);
m_columnNamePolicy.loadSettingsFrom(settings, specs);
m_valueDelimiter.loadSettingsFrom(settings, specs);
m_maxNoneNumericVals.loadSettingsFrom(settings, specs);
try {
m_aggrColPanel.loadSettingsFrom(settings, specs[0]);
} catch (InvalidSettingsException e) {
throw new NotConfigurableException(e.getMessage(), e);
}
try {
m_patternAggrPanel.loadSettingsFrom(settings, specs[0]);
m_dataTypeAggrPanel.loadSettingsFrom(settings, specs[0]);
} catch (InvalidSettingsException e) {
// introduced in 2.11
}
}
Aggregations