Search in sources :

Example 1 with PMMLModelType

use of org.knime.core.pmml.PMMLModelType in project knime-core by knime.

the class PMMLMiningSchemaTranslator method initializeFrom.

/**
 * Initializes the mining schema translator based on a PMML document.
 * See {@link PMMLTranslator#initializeFrom(PMMLDocument)}
 * @param pmmlDoc the PMML document
 */
public void initializeFrom(final PMMLDocument pmmlDoc) {
    Map<PMMLModelType, Integer> models = PMMLUtils.getNumberOfModels(pmmlDoc);
    if (models.isEmpty()) {
        LOGGER.warn("The PMML document contains no model. Hence no " + "mining schema could be found.");
        return;
    }
    // retrieve the first models mining schema
    MiningSchema miningSchema = PMMLUtils.getFirstMiningSchema(pmmlDoc, models.keySet().iterator().next().getXmlBeansType());
    for (MiningField miningField : miningSchema.getMiningFieldArray()) {
        if (miningField.isSetMissingValueReplacement()) {
            LOGGER.warn("\"missingValueReplacement\" is not supported and " + "will be ignored. Skipping it");
        }
        if (miningField.isSetMissingValueTreatment()) {
            LOGGER.warn("\"missingValueTreatment\" is not supported and " + "will be ignored. Skipping it");
        }
        if (miningField.isSetOutliers()) {
            LOGGER.warn("\"outliers\" is not supported and " + "will be ignored. Skipping it");
        }
        checkInvalidValueTreatment(pmmlDoc, miningField);
        String name = miningField.getName();
        FIELDUSAGETYPE.Enum usageType = miningField.getUsageType();
        if (FIELDUSAGETYPE.ACTIVE == usageType) {
            m_learningFields.add(name);
        } else if (FIELDUSAGETYPE.PREDICTED == usageType || FIELDUSAGETYPE.TARGET == usageType) {
            m_targetFields.add(name);
        }
    }
}
Also used : MiningField(org.dmg.pmml.MiningFieldDocument.MiningField) MiningSchema(org.dmg.pmml.MiningSchemaDocument.MiningSchema) PMMLModelType(org.knime.core.pmml.PMMLModelType) FIELDUSAGETYPE(org.dmg.pmml.FIELDUSAGETYPE)

Example 2 with PMMLModelType

use of org.knime.core.pmml.PMMLModelType in project knime-core by knime.

the class PMMLPortObject method getSummary.

/**
 * {@inheritDoc}
 */
@Override
public String getSummary() {
    StringBuffer sb = new StringBuffer();
    sb.append("PMML document with version ");
    sb.append(m_pmmlDoc.getPMML().getVersion());
    sb.append(" and models: ");
    boolean first = true;
    for (PMMLModelType modelType : PMMLUtils.getNumberOfModels(m_pmmlDoc).keySet()) {
        if (!first) {
            sb.append(",");
        } else {
            first = false;
        }
        sb.append(modelType);
    }
    return sb.toString();
}
Also used : PMMLModelType(org.knime.core.pmml.PMMLModelType)

Aggregations

PMMLModelType (org.knime.core.pmml.PMMLModelType)2 FIELDUSAGETYPE (org.dmg.pmml.FIELDUSAGETYPE)1 MiningField (org.dmg.pmml.MiningFieldDocument.MiningField)1 MiningSchema (org.dmg.pmml.MiningSchemaDocument.MiningSchema)1