use of org.dmg.pmml.ExtensionDocument.Extension in project knime-core by knime.
the class GBTRegressionTreeModelExporter method addExtension.
/**
* {@inheritDoc}
*/
@Override
protected void addExtension(final Node pmmlNode, final TreeNodeRegression node) {
super.addExtension(pmmlNode, node);
// store the gbt coefficient for leafs
if (node.getNrChildren() == 0) {
Extension ext = pmmlNode.addNewExtension();
ext.setName(TranslationUtil.MEAN_KEY);
CheckUtils.checkArgument(m_coefficientMap.containsKey(node.getSignature()), "The GBT model contains no coefficient for the leaf %s.", node);
ext.setValue(Double.toString(node.getMean()));
}
}
use of org.dmg.pmml.ExtensionDocument.Extension in project knime-core by knime.
the class RegressionTreeModelExporter method addExtension.
protected void addExtension(final Node pmmlNode, final TreeNodeRegression node) {
Extension ext = pmmlNode.addNewExtension();
ext.setName(TranslationUtil.SUM_SQUARED_DEVIATION_KEY);
ext.setValue(Double.toString(node.getSumSquaredDeviation()));
ext = pmmlNode.addNewExtension();
ext.setName(TranslationUtil.TOTAL_SUM_KEY);
ext.setValue(Double.toString(node.getTotalSum()));
}
use of org.dmg.pmml.ExtensionDocument.Extension in project knime-core by knime.
the class PMMLNormalizeTranslator method createSummaryExtension.
private Extension[] createSummaryExtension() {
Extension extension = Extension.Factory.newInstance();
extension.setName(SUMMARY);
extension.setExtender(PMMLPortObjectSpec.KNIME);
extension.setValue(m_affineTrans.getSummary());
return new Extension[] { extension };
}
use of org.dmg.pmml.ExtensionDocument.Extension in project knime-core by knime.
the class PMMLMapValuesTranslator method createSummaryExtension.
private Extension[] createSummaryExtension() {
Extension extension = Extension.Factory.newInstance();
extension.setName("summary");
extension.setExtender(PMMLPortObjectSpec.KNIME);
extension.setValue(m_config.getSummary());
return new Extension[] { extension };
}
use of org.dmg.pmml.ExtensionDocument.Extension in project knime-core by knime.
the class MissingCellHandler method createExtensionDerivedField.
/**
* Creates a derived field that contains an extension which
* contains the name of the factory to use for the replacement.
* The result may be adjusted to contain necessary information for the handler.
* @param dataType the data type of the derived field
* @param factoryID the id of the factory
* @return the derived field
*/
protected DerivedField createExtensionDerivedField(final DATATYPE.Enum dataType, final String factoryID) {
DerivedField field = DerivedField.Factory.newInstance();
if (dataType == org.dmg.pmml.DATATYPE.STRING || dataType == org.dmg.pmml.DATATYPE.BOOLEAN) {
field.setOptype(org.dmg.pmml.OPTYPE.CATEGORICAL);
} else {
field.setOptype(org.dmg.pmml.OPTYPE.CONTINUOUS);
}
Extension e = field.addNewExtension();
e.setName(CUSTOM_HANDLER_EXTENSION_NAME);
e.setValue(factoryID);
field.setDataType(dataType);
field.setName(m_col.getName());
field.setDisplayName(m_col.getName());
// Insert settings
NodeSettings nodeSettings = new NodeSettings("");
saveSettingsTo(nodeSettings);
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
nodeSettings.saveToXML(baos);
Document doc = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
Node copy = e.getDomNode().getOwnerDocument().importNode(doc.getFirstChild(), true);
e.getDomNode().appendChild(copy);
} catch (Exception ex) {
LOGGER.error("An error occurred while writing settings to PMML.\n" + ex.getMessage());
return null;
}
return field;
}
Aggregations