Search in sources :

Example 1 with PMMLMiningSchemaTranslator

use of org.knime.core.node.port.pmml.PMMLMiningSchemaTranslator in project knime-core by knime.

the class PMMLImport method init.

/**
 * @param pmmlDoc
 */
private void init(final PMMLDocument pmmlDoc) {
    PMMLDataDictionaryTranslator dictTrans = new PMMLDataDictionaryTranslator();
    dictTrans.initializeFrom(pmmlDoc);
    DataTableSpec tableSpec = dictTrans.getDataTableSpec();
    List<String> activeDerivedFields = dictTrans.getActiveDerivedFields();
    PMMLPortObjectSpecCreator specCreator = new PMMLPortObjectSpecCreator(tableSpec);
    PMMLMiningSchemaTranslator miningTrans = new PMMLMiningSchemaTranslator();
    miningTrans.initializeFrom(pmmlDoc);
    Set<String> activeFields = new LinkedHashSet<String>();
    List<String> miningFields = miningTrans.getActiveFields();
    /* If we have a model all active fields of the data dictionary
         * are passed through the mining schema. */
    activeFields.addAll(miningFields);
    activeFields.addAll(activeDerivedFields);
    specCreator.setLearningColsNames(new LinkedList<String>(activeFields));
    specCreator.addPreprocColNames(activeDerivedFields);
    specCreator.setTargetColsNames(miningTrans.getTargetFields());
    PMMLPortObjectSpec portObjectSpec = specCreator.createSpec();
    m_portObject = new PMMLPortObject(portObjectSpec, pmmlDoc);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PMMLMiningSchemaTranslator(org.knime.core.node.port.pmml.PMMLMiningSchemaTranslator) DataTableSpec(org.knime.core.data.DataTableSpec) PMMLPortObjectSpec(org.knime.core.node.port.pmml.PMMLPortObjectSpec) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) PMMLDataDictionaryTranslator(org.knime.core.node.port.pmml.PMMLDataDictionaryTranslator) PMMLPortObjectSpecCreator(org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 PMMLDataDictionaryTranslator (org.knime.core.node.port.pmml.PMMLDataDictionaryTranslator)1 PMMLMiningSchemaTranslator (org.knime.core.node.port.pmml.PMMLMiningSchemaTranslator)1 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)1 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)1 PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)1