use of org.knime.base.node.mine.sota.SotaPortObjectSpec in project knime-core by knime.
the class SotaPredictorNodeFactory method createNodeDialogPane.
/**
* {@inheritDoc}
*/
@Override
protected NodeDialogPane createNodeDialogPane() {
return new PredictorNodeDialog(SotaPredictorNodeModel.createAppendProbabilities()) {
/**
* {@inheritDoc}
*/
@Override
protected void extractTargetColumn(final PortObjectSpec[] specs) {
if (specs[0] instanceof SotaPortObjectSpec) {
final SotaPortObjectSpec sotaSpec = (SotaPortObjectSpec) specs[0];
final DataColumnSpec classColumnSpec = sotaSpec.getClassColumnSpec();
setLastTargetColumn(classColumnSpec == null ? new DataColumnSpecCreator("No class", StringCell.TYPE).createSpec() : classColumnSpec);
} else {
throw new IllegalArgumentException("Wrong input: " + specs[0].getClass());
}
}
};
}
use of org.knime.base.node.mine.sota.SotaPortObjectSpec in project knime-core by knime.
the class SotaPredictorNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
if (!(inData[1] instanceof BufferedDataTable)) {
throw new IllegalArgumentException("Given inport object at " + "index 0 is not a BufferedDataTable!");
} else if (!(inData[0] instanceof SotaPortObject)) {
throw new IllegalArgumentException("Given inport object at " + "index 1 is not a SotaPortObject");
}
BufferedDataTable bdt = (BufferedDataTable) inData[1];
SotaPortObject spo = (SotaPortObject) inData[0];
exec.checkCanceled();
// build data table to use
int[] indicesOfIncludedCols = new int[bdt.getDataTableSpec().getNumColumns()];
for (int i = 0; i < bdt.getDataTableSpec().getNumColumns(); i++) {
indicesOfIncludedCols[i] = i;
}
exec.checkCanceled();
ColumnRearranger cr = new ColumnRearranger(bdt.getDataTableSpec());
final SotaPortObjectSpec sotaSpec = (SotaPortObjectSpec) spo.getSpec();
cr.append(new SotaPredictorCellFactory(spo.getSotaRoot(), indicesOfIncludedCols, spo.getDistance(), m_appendProbs.getBooleanValue(), sotaSpec.getClassColumnSpec(), m_probSuffix.getStringValue(), createOutColSpecs(sotaSpec)));
return new BufferedDataTable[] { exec.createColumnRearrangeTable(bdt, cr, exec) };
}
Aggregations