use of org.knime.base.node.mine.treeensemble2.model.pmml.RegressionTreeModelPMMLTranslator in project knime-core by knime.
the class RegressionTreePMMLTranslatorNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
final RegressionTreeModelPortObject treePO = (RegressionTreeModelPortObject) inObjects[0];
final RegressionTreeModel model = treePO.getModel();
final RegressionTreeModelPortObjectSpec treeSpec = treePO.getSpec();
PMMLPortObjectSpec pmmlSpec = createPMMLSpec(treeSpec, model);
PMMLPortObject portObject = new PMMLPortObject(pmmlSpec);
final TreeModelRegression tree = model.getTreeModel();
final RegressionTreeModelPMMLTranslator translator = new RegressionTreeModelPMMLTranslator(tree, model.getMetaData(), treeSpec.getLearnTableSpec());
portObject.addModelTranslater(translator);
if (translator.hasWarning()) {
setWarningMessage(translator.getWarning());
}
return new PortObject[] { portObject };
}
use of org.knime.base.node.mine.treeensemble2.model.pmml.RegressionTreeModelPMMLTranslator in project knime-core by knime.
the class RegressionTreePMMLPredictorNodeModel method importModel.
private Pair<RegressionTreeModel, RegressionTreeModelPortObjectSpec> importModel(final PMMLPortObject pmmlPO) {
RegressionTreeModelPMMLTranslator pmmlTranslator = new RegressionTreeModelPMMLTranslator();
pmmlPO.initializeModelTranslator(pmmlTranslator);
if (pmmlTranslator.hasWarning()) {
setWarningMessage(pmmlTranslator.getWarning());
}
return new Pair<>(new RegressionTreeModel(pmmlTranslator.getTreeMetaData(), pmmlTranslator.getTree(), TreeType.Ordinary), new RegressionTreeModelPortObjectSpec(pmmlTranslator.getLearnSpec()));
}
use of org.knime.base.node.mine.treeensemble2.model.pmml.RegressionTreeModelPMMLTranslator in project knime-core by knime.
the class RegressionTreeModelPortObject method createDecisionTreePMMLPortObject.
public PMMLPortObject createDecisionTreePMMLPortObject() {
final RegressionTreeModel model = getModel();
DataTableSpec attributeLearnSpec = model.getLearnAttributeSpec(m_spec.getLearnTableSpec());
DataColumnSpec targetSpec = m_spec.getTargetColumn();
PMMLPortObjectSpecCreator pmmlSpecCreator = new PMMLPortObjectSpecCreator(new DataTableSpec(attributeLearnSpec, new DataTableSpec(targetSpec)));
try {
pmmlSpecCreator.setLearningCols(attributeLearnSpec);
} catch (InvalidSettingsException e) {
// (as of KNIME v2.5.1)
throw new IllegalStateException(e);
}
pmmlSpecCreator.setTargetCol(targetSpec);
PMMLPortObjectSpec pmmlSpec = pmmlSpecCreator.createSpec();
PMMLPortObject portObject = new PMMLPortObject(pmmlSpec);
final TreeModelRegression tree = model.getTreeModel();
portObject.addModelTranslater(new RegressionTreeModelPMMLTranslator(tree, model.getMetaData(), m_spec.getLearnTableSpec()));
return portObject;
}
Aggregations