use of org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator in project knime-core by knime.
the class NumberToStringNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec dts = (DataTableSpec) inSpecs[0];
// find indices to work on
int[] indices = findColumnIndices(dts);
ConverterFactory converterFac = new ConverterFactory(indices, dts);
ColumnRearranger colre = new ColumnRearranger(dts);
colre.replace(converterFac, indices);
DataTableSpec outDataSpec = colre.createSpec();
// create the PMML spec based on the optional incoming PMML spec
PMMLPortObjectSpec pmmlSpec = m_pmmlInEnabled ? (PMMLPortObjectSpec) inSpecs[1] : null;
PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, dts);
return new PortObjectSpec[] { outDataSpec, pmmlSpecCreator.createSpec() };
}
use of org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator in project knime-core by knime.
the class RegressionContent method createSpec.
/**
* @param spec The input table spec.
* @param target The target column name.
* @param learningCols The columns used for learning.
* @return The {@link PMMLPortObjectSpec} to corresponding to the generated {@link PMMLPortObject}.
*/
protected static PMMLPortObjectSpec createSpec(final DataTableSpec spec, final String target, final String[] learningCols) {
PMMLPortObjectSpecCreator c = new PMMLPortObjectSpecCreator(spec);
c.setTargetColName(target);
c.setLearningColsNames(Arrays.asList(learningCols));
return c.createSpec();
}
use of org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator in project knime-core by knime.
the class SVMLearnerNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec inSpec = (DataTableSpec) inSpecs[0];
PMMLPortObjectSpec portSpec = m_pmmlInEnabled ? (PMMLPortObjectSpec) inSpecs[1] : null;
LearnColumnsAndColumnRearrangerTuple tuple = createTrainTableColumnRearranger(inSpec);
DataTableSpec trainSpec = tuple.getTrainingRearranger().createSpec();
PMMLPortObjectSpecCreator pmmlcreate = new PMMLPortObjectSpecCreator(portSpec, trainSpec);
pmmlcreate.setTargetCol(tuple.getTargetColumn());
pmmlcreate.setLearningCols(tuple.getLearningColumns());
return new PortObjectSpec[] { pmmlcreate.createSpec() };
}
use of org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator in project knime-core by knime.
the class RPropNodeModel method createPMMLPortObjectSpec.
private PMMLPortObjectSpec createPMMLPortObjectSpec(final PMMLPortObjectSpec pmmlSpec, final DataTableSpec spec, final List<String> learningCols, final List<String> targetCols) {
PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(pmmlSpec, spec);
pmmlSpecCreator.setLearningColsNames(learningCols);
pmmlSpecCreator.setTargetColsNames(targetCols);
return pmmlSpecCreator.createSpec();
}
use of org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator in project knime-core by knime.
the class PMMLKNNNodeModel method createSpec.
/**
* @param dataTableSpec
* @return
* @throws InvalidSettingsException when the input table contains invalid columns
*/
private PMMLPortObjectSpec createSpec(final DataTableSpec dataTableSpec) throws InvalidSettingsException {
List<DataColumnSpec> learningColumns = new ArrayList<DataColumnSpec>();
DataTableSpecCreator dataDictCreator = new DataTableSpecCreator();
String[] selectedColumns = m_learningColumns.applyTo(dataTableSpec).getIncludes();
if (selectedColumns.length == 0) {
throw new InvalidSettingsException("No learning columns are selected.");
}
for (String lc : selectedColumns) {
DataColumnSpec cs = dataTableSpec.getColumnSpec(lc);
dataDictCreator.addColumns(cs);
learningColumns.add(cs);
}
if (m_predColumnName.getStringValue() == null || !dataTableSpec.containsName(m_predColumnName.getStringValue())) {
for (int i = 0; i < dataTableSpec.getNumColumns(); i++) {
DataColumnSpec cspec = dataTableSpec.getColumnSpec(i);
if (cspec.getType().isCompatible(StringValue.class)) {
m_predColumnName.setStringValue(cspec.getName());
setWarningMessage("No target column selected. Using \"" + cspec.getName() + "\".");
break;
}
}
}
if (m_predColumnName.getStringValue() == null) {
throw new InvalidSettingsException("The table does not contain a suitable target column.");
}
dataDictCreator.addColumns(dataTableSpec.getColumnSpec(m_predColumnName.getStringValue()));
PMMLPortObjectSpecCreator specCreator = new PMMLPortObjectSpecCreator(dataDictCreator.createSpec());
specCreator.setTargetCol(dataTableSpec.getColumnSpec(m_predColumnName.getStringValue()));
specCreator.setLearningCols(learningColumns);
return specCreator.createSpec();
}
Aggregations