Search code examples
knimepmml

Generating PMML in Knime module


I'm currently attempting to build module for the Knime analytics platform. This is going to be a module that generates and passes on a PMML model as its output.

So far I've only been able to accomplish this by manually creating a PMMLDocument and then creating a new PMMLPortObject((PMMLPortObjectSpec)out_spec, pmmlDoc) to return.

My question is whether creating the pmml doc itself manually is the right approach here, or is there any other more streamlined method to do this, maybe via templating or something similar ?

Currently, generating a pmml model manually like so:

    PMMLDocument resDoc = PMMLDocument.Factory.newInstance();
    PMML pmml = PMML.Factory.newInstance();
    pmml.setVersion("4.2");

    Header header = pmml.addNewHeader();
    header.setCopyright("some custom made copyright");
    Application application = header.addNewApplication();
    application.setName("KNIME");
    application.setVersion("2.10.3");
    ...

Can get quite tedious and it makes me wonder where this is actually a best practice or not


Solution

  • Yes, that is pretty much it. The PMML Standard is an XML specification, so what you're doing is filling out all of the fields for the spec. Usually you would write a procedure that would be called for each similar repetitive subpart of your model, e.g., a node in a Decision Tree.

    And, yes it is quite repetitive until you get the structure down.