我正在尝试在JPMML中创建逻辑回归模型,然后将PMML写入文件。我遇到的问题是,在下面的示例中,我找不到任何创建自定义标签的方法,例如“ Shortform”和“ Longform”:

<MapValues outputColumn="longForm">
  <FieldColumnPair field="gender" column="shortForm"/>
  <InlineTable>
    <row><shortForm>m</shortForm><longForm>male</longForm>
    </row>
    <row><shortForm>f</shortForm><longForm>female</longForm>
    </row>
  </InlineTable>
</MapValues>

这是我到目前为止所拥有的:

MapValues mv = new MapValues("output")
  .withFieldColumnPairs(
        new FieldColumnPair( new FieldName("gender"), "shortForm" )
  ).withInlineTable(
        new InlineTable().withRows(
                new Row().with???( new ??? )
)))

简而言之,我要求使用一个API调用,可以用来实例化示例中的“短形式”元素,然后将其附加到“行”对象上。我已经经历了API,示例和Google/So,但找不到东西。

谢谢你的帮助!

有帮助吗?

解决方案

您可以/应该使用XML绑定(JAXB)方法的通用Java架构。

简单地说,打电话 Row#withContent(Object...) 与实例 org.w3c.dom.Element 代表所需的XML内容。

例如:

Document document = documentBuilder.newDocument();
Element shortForm = document.createElement("shortForm");
shortForm.setTextContent("m");
Element longForm = document.createElement("longForm");
longForm.setTextContent("male");
row = row.withContent(shortForm, longForm);
许可以下: CC-BY-SA归因
scroll top