Search in sources :

Example 1 with RegressionTreeModelPMMLTranslator

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 };
}
Also used : RegressionTreeModelPortObject(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObject) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) RegressionTreeModel(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModel) RegressionTreeModelPortObjectSpec(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObjectSpec) RegressionTreeModelPortObject(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObject) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PortObject(org.knime.core.node.port.PortObject) TreeModelRegression(org.knime.base.node.mine.treeensemble2.model.TreeModelRegression) RegressionTreeModelPMMLTranslator(org.knime.base.node.mine.treeensemble2.model.pmml.RegressionTreeModelPMMLTranslator)

Example 2 with RegressionTreeModelPMMLTranslator

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()));
}
Also used : RegressionTreeModel(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModel) RegressionTreeModelPortObjectSpec(org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObjectSpec) RegressionTreeModelPMMLTranslator(org.knime.base.node.mine.treeensemble2.model.pmml.RegressionTreeModelPMMLTranslator) Pair(org.knime.core.util.Pair)

Example 3 with RegressionTreeModelPMMLTranslator

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;
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator) RegressionTreeModelPMMLTranslator(org.knime.base.node.mine.treeensemble2.model.pmml.RegressionTreeModelPMMLTranslator)

Aggregations

RegressionTreeModelPMMLTranslator (org.knime.base.node.mine.treeensemble2.model.pmml.RegressionTreeModelPMMLTranslator)3 RegressionTreeModel (org.knime.base.node.mine.treeensemble2.model.RegressionTreeModel)2 RegressionTreeModelPortObjectSpec (org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObjectSpec)2 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)2 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)2 RegressionTreeModelPortObject (org.knime.base.node.mine.treeensemble2.model.RegressionTreeModelPortObject)1 TreeModelRegression (org.knime.base.node.mine.treeensemble2.model.TreeModelRegression)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 PortObject (org.knime.core.node.port.PortObject)1 PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)1 Pair (org.knime.core.util.Pair)1