use of org.knime.core.node.port.pmml.PMMLPortObjectSpec in project knime-core by knime.
the class NaiveBayesPredictorNodeDialog2 method extractTargetColumn.
/**
* {@inheritDoc}
*/
@Override
protected void extractTargetColumn(final PortObjectSpec[] specs) {
if (specs[0] instanceof PMMLPortObjectSpec) {
PMMLPortObjectSpec spec = (PMMLPortObjectSpec) specs[0];
final List<DataColumnSpec> targetCols = spec.getTargetCols();
if (targetCols.size() != 1) {
throw new IllegalStateException("No valid class column found");
}
final DataColumnSpec targetColumn = targetCols.get(0);
setLastTargetColumn(targetColumn);
} else {
throw new IllegalStateException(specs[0].getClass().toString());
}
}
use of org.knime.core.node.port.pmml.PMMLPortObjectSpec in project knime-core by knime.
the class One2ManyCol2PMMLNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec inDataSpec = (DataTableSpec) inSpecs[0];
m_appendOrgColName = false;
String[] includes = m_includedColumns.applyTo(inDataSpec).getIncludes();
if (includes.length <= 0) {
setWarningMessage("No columns to transfrom selected. Will have no effect!");
}
// check if the values are present in the current spec
if (includes.length > 0) {
checkColumnsSpecs(inDataSpec);
}
CellFactory cellFactory = new One2ManyCellFactory(inDataSpec, Arrays.asList(includes), m_appendOrgColName);
ColumnRearranger rearranger = createRearranger(inDataSpec, cellFactory);
if (m_pmmlOutEnabled) {
PMMLPortObjectSpec pmmlSpec = m_pmmlInEnabled ? (PMMLPortObjectSpec) inSpecs[1] : null;
PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, inDataSpec);
return new PortObjectSpec[] { rearranger.createSpec(), pmmlSpecCreator.createSpec() };
} else {
return new PortObjectSpec[] { rearranger.createSpec() };
}
}
use of org.knime.core.node.port.pmml.PMMLPortObjectSpec in project knime-core by knime.
the class AbstractNormalizerPMMLNodeModel method prepareConfigure.
/**
* @param inSpecs An array of DataTableSpecs (as many as this model has
* inputs).
* @return An array of DataTableSpecs (as many as this model has outputs)
*
* @throws InvalidSettingsException if the <code>#configure()</code> failed,
* that is, the settings are inconsistent with given
* DataTableSpec elements.
*/
@Override
protected PortObjectSpec[] prepareConfigure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec spec = (DataTableSpec) inSpecs[0];
PMMLPortObjectSpecCreator pmmlSpecCreator;
if (m_hasModelIn) {
PMMLPortObjectSpec pmmlSpec = (PMMLPortObjectSpec) inSpecs[1];
// extract selected numeric columns
updateNumericColumnSelection(spec);
if (getMode() == NONORM_MODE) {
return new PortObjectSpec[] { spec, pmmlSpec };
}
pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, spec);
} else {
// extract selected numeric columns
updateNumericColumnSelection(spec);
if (getMode() == NONORM_MODE) {
return new PortObjectSpec[] { spec };
}
pmmlSpecCreator = new PMMLPortObjectSpecCreator(spec);
}
return new PortObjectSpec[] { Normalizer2.generateNewSpec(spec, getColumns()), pmmlSpecCreator.createSpec() };
}
use of org.knime.core.node.port.pmml.PMMLPortObjectSpec in project knime-core by knime.
the class CategoryToNumberNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec inSpec = (DataTableSpec) inSpecs[0];
List<String> inputCols = new ArrayList<String>();
for (DataColumnSpec column : inSpec) {
if (column.getType().isCompatible(StringValue.class)) {
inputCols.add(column.getName());
}
}
FilterResult filter = m_settings.getFilterConfiguration().applyTo(inSpec);
String[] rmFromIncl = filter.getRemovedFromIncludes();
if (m_settings.getFilterConfiguration().isEnforceInclusion() && rmFromIncl.length != 0) {
throw new InvalidSettingsException("Input table does not contain the following selected column(s): " + ConvenienceMethods.getShortStringFrom(new HashSet<String>(Arrays.asList(rmFromIncl)), 3));
}
m_included = filter.getIncludes();
if (m_included.length == 0) {
setWarningMessage("No columns selected.");
}
ColumnRearranger rearranger = createRearranger(inSpec);
PMMLPortObjectSpec pmmlSpec = m_pmmlInEnabled ? (PMMLPortObjectSpec) inSpecs[1] : null;
PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, inSpec);
pmmlSpecCreator.addPreprocColNames(inputCols);
return new PortObjectSpec[] { rearranger.createSpec(), pmmlSpecCreator.createSpec() };
}
use of org.knime.core.node.port.pmml.PMMLPortObjectSpec in project knime-core by knime.
the class DecTreePredictorNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
PMMLPortObjectSpec treeSpec = (PMMLPortObjectSpec) inSpecs[INMODELPORT];
DataTableSpec inSpec = (DataTableSpec) inSpecs[1];
for (String learnColName : treeSpec.getLearningFields()) {
if (!inSpec.containsName(learnColName)) {
throw new InvalidSettingsException("Learning column \"" + learnColName + "\" not found in input " + "data to be predicted");
}
}
return new PortObjectSpec[] { createOutTableSpec(inSpecs) };
}
Aggregations