use of org.knime.core.node.port.pmml.PMMLPortObjectSpec in project knime-core by knime.
the class PMMLRuleEditorNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
RuleSet ruleSet = RuleSet.Factory.newInstance();
PMMLRuleParser parser = new PMMLRuleParser((DataTableSpec) inSpecs[0], getAvailableInputFlowVariables());
try {
ColumnRearranger rearranger = createRearranger((DataTableSpec) inSpecs[0], ruleSet, parser);
PMMLPortObjectSpec portObjectSpec = createPMMLPortObjectSpec(rearranger.createSpec(), Collections.<String>emptyList());
return new PortObjectSpec[] { rearranger.createSpec(), portObjectSpec };
} catch (ParseException e) {
throw new InvalidSettingsException(e);
}
}
use of org.knime.core.node.port.pmml.PMMLPortObjectSpec in project knime-core by knime.
the class DecisionTreeLearnerNodeModel method configure.
/**
* The number of the class column must be > 0 and < number of input columns.
*
* @param inSpecs the tabel specs on the input port to use for configuration
* @see NodeModel#configure(DataTableSpec[])
* @throws InvalidSettingsException thrown if the configuration is not
* correct
* @return the table specs for the output ports
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec inSpec = (DataTableSpec) inSpecs[DATA_INPORT];
PMMLPortObjectSpec modelSpec = (PMMLPortObjectSpec) inSpecs[MODEL_INPORT];
// check spec with selected column
String classifyColumn = m_classifyColumn.getStringValue();
DataColumnSpec columnSpec = inSpec.getColumnSpec(classifyColumn);
boolean isValid = columnSpec != null && columnSpec.getType().isCompatible(NominalValue.class);
if (classifyColumn != null && !isValid) {
throw new InvalidSettingsException("Class column \"" + classifyColumn + "\" not found or incompatible");
}
if (classifyColumn == null) {
// auto-guessing
assert !isValid : "No class column set but valid configuration";
// get the first useful one starting at the end of the table
for (int i = inSpec.getNumColumns() - 1; i >= 0; i--) {
if (inSpec.getColumnSpec(i).getType().isCompatible(NominalValue.class)) {
m_classifyColumn.setStringValue(inSpec.getColumnSpec(i).getName());
super.setWarningMessage("Guessing target column: \"" + m_classifyColumn.getStringValue() + "\".");
break;
}
}
if (m_classifyColumn.getStringValue() == null) {
throw new InvalidSettingsException("Table contains no nominal" + " attribute for classification.");
}
}
return new PortObjectSpec[] { createPMMLPortObjectSpec(modelSpec, inSpec) };
}
Aggregations