use of org.knime.core.node.ExecutionContext in project knime-core by knime.
the class RandomForestProximityNodeModel method execute.
@Override
protected BufferedDataTable[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
TreeEnsembleModelPortObject model = (TreeEnsembleModelPortObject) inObjects[0];
BufferedDataTable table1 = (BufferedDataTable) inObjects[1];
BufferedDataTable table2 = (BufferedDataTable) inObjects[2];
BufferedDataTable[] tables;
if (table2 != null) {
tables = new BufferedDataTable[] { table1, table2 };
} else {
tables = new BufferedDataTable[] { table1 };
}
ExecutionContext calcExec = exec.createSubExecutionContext(0.7);
ExecutionContext writeExec = exec.createSubExecutionContext(0.3);
exec.setMessage("Calculating Proximity");
ProximityMatrix pm = null;
ProximityMeasure proximityMeasure = ProximityMeasure.valueOf(m_proximityMeasure.getStringValue());
switch(proximityMeasure) {
case PathProximity:
pm = new PathProximity(tables, model).calculatePathProximities(calcExec);
break;
case Proximity:
pm = Proximity.calcProximities(tables, model, calcExec);
break;
default:
throw new IllegalStateException("Illegal proximity measure encountered.");
}
exec.setMessage("Writing");
return new BufferedDataTable[] { pm.createTable(writeExec) };
}
use of org.knime.core.node.ExecutionContext in project knime-core by knime.
the class RegressionTreePMMLPredictorNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
PMMLPortObject model = (PMMLPortObject) ((PortObjectInput) inputs[0]).getPortObject();
DataTableSpec dataSpec = (DataTableSpec) inSpecs[1];
Pair<RegressionTreeModel, RegressionTreeModelPortObjectSpec> treeSpecPair = importModel(model);
final RegressionTreePredictor pred = new RegressionTreePredictor(treeSpecPair.getFirst(), treeSpecPair.getSecond(), dataSpec, m_configuration);
ColumnRearranger rearranger = pred.getPredictionRearranger();
StreamableFunction func = rearranger.createStreamableFunction(1, 0);
func.runFinal(inputs, outputs, exec);
}
};
}
use of org.knime.core.node.ExecutionContext in project knime-core by knime.
the class RegressionTreePredictorNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
RegressionTreeModelPortObject model = (RegressionTreeModelPortObject) ((PortObjectInput) inputs[0]).getPortObject();
DataTableSpec dataSpec = (DataTableSpec) inSpecs[1];
final RegressionTreePredictor pred = new RegressionTreePredictor(model.getModel(), model.getSpec(), dataSpec, m_configuration);
ColumnRearranger rearranger = pred.getPredictionRearranger();
StreamableFunction func = rearranger.createStreamableFunction(1, 0);
func.runFinal(inputs, outputs, exec);
}
};
}
use of org.knime.core.node.ExecutionContext in project knime-core by knime.
the class GradientBoostingClassificationPredictorNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
GradientBoostingModelPortObject model = (GradientBoostingModelPortObject) ((PortObjectInput) inputs[0]).getPortObject();
TreeEnsembleModelPortObjectSpec modelSpec = model.getSpec();
DataTableSpec dataSpec = (DataTableSpec) inSpecs[1];
final GradientBoostingPredictor<MultiClassGradientBoostedTreesModel> pred = new GradientBoostingPredictor<>((MultiClassGradientBoostedTreesModel) model.getEnsembleModel(), modelSpec, dataSpec, m_configuration);
ColumnRearranger rearranger = pred.getPredictionRearranger();
StreamableFunction func = rearranger.createStreamableFunction(1, 0);
func.runFinal(inputs, outputs, exec);
}
};
}
use of org.knime.core.node.ExecutionContext in project knime-core by knime.
the class GradientBoostingPredictorNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
GradientBoostingModelPortObject model = (GradientBoostingModelPortObject) ((PortObjectInput) inputs[0]).getPortObject();
TreeEnsembleModelPortObjectSpec modelSpec = model.getSpec();
DataTableSpec dataSpec = (DataTableSpec) inSpecs[1];
final GradientBoostingPredictor<GradientBoostedTreesModel> pred = new GradientBoostingPredictor<>((GradientBoostedTreesModel) model.getEnsembleModel(), modelSpec, dataSpec, m_configuration);
ColumnRearranger rearranger = pred.getPredictionRearranger();
StreamableFunction func = rearranger.createStreamableFunction(1, 0);
func.runFinal(inputs, outputs, exec);
}
};
}
Aggregations