Search in sources :

Example 1 with TargetValueCount

use of org.dmg.pmml.TargetValueCountDocument.TargetValueCount in project knime-core by knime.

the class ClassAttributeModel method exportClassAttributeToPMML.

/**
 * @param out the PMML {@link BayesOutput} to write the class counts to
 */
void exportClassAttributeToPMML(final BayesOutput out) {
    out.setFieldName(getAttributeName());
    if (!ignoreMissingVals()) {
        PMMLNaiveBayesModelTranslator.setIntExtension(out.addNewExtension(), NO_OF_MISSING_VALUES, getNoOfMissingVals());
    }
    final TargetValueCounts targetValueCounts = out.addNewTargetValueCounts();
    for (final String classVal : m_recsCounterByClassVal.keySet()) {
        final TargetValueCount targetValueCount = targetValueCounts.addNewTargetValueCount();
        targetValueCount.setValue(classVal);
        targetValueCount.setCount(m_recsCounterByClassVal.get(classVal).doubleValue());
    }
}
Also used : TargetValueCounts(org.dmg.pmml.TargetValueCountsDocument.TargetValueCounts) TargetValueCount(org.dmg.pmml.TargetValueCountDocument.TargetValueCount)

Example 2 with TargetValueCount

use of org.dmg.pmml.TargetValueCountDocument.TargetValueCount in project knime-core by knime.

the class NominalAttributeModel method exportToPMMLInternal.

/**
 * {@inheritDoc}
 */
@Override
void exportToPMMLInternal(final BayesInput bayesInput) {
    for (final String attributeValue : m_attributeVals) {
        PairCounts pairCounts = bayesInput.addNewPairCounts();
        pairCounts.setValue(attributeValue);
        final TargetValueCounts targetValueCounts = pairCounts.addNewTargetValueCounts();
        for (final NominalClassValue classVal : m_classValues.values()) {
            final TargetValueCount targetValueCount = targetValueCounts.addNewTargetValueCount();
            if (!ignoreMissingVals()) {
                PMMLNaiveBayesModelTranslator.setIntExtension(targetValueCount.addNewExtension(), NominalClassValue.MISSING_VALUE_COUNTER, classVal.getNoOfMissingValueRecs());
            }
            targetValueCount.setValue(classVal.getClassValue());
            final MutableInteger attrCount = classVal.m_recsByAttrValue.get(attributeValue);
            final int count;
            if (attrCount != null) {
                count = attrCount.intValue();
            } else {
                count = 0;
            }
            targetValueCount.setCount(count);
        }
    }
}
Also used : PairCounts(org.dmg.pmml.PairCountsDocument.PairCounts) TargetValueCounts(org.dmg.pmml.TargetValueCountsDocument.TargetValueCounts) MutableInteger(org.knime.core.util.MutableInteger) TargetValueCount(org.dmg.pmml.TargetValueCountDocument.TargetValueCount)

Aggregations

TargetValueCount (org.dmg.pmml.TargetValueCountDocument.TargetValueCount)2 TargetValueCounts (org.dmg.pmml.TargetValueCountsDocument.TargetValueCounts)2 PairCounts (org.dmg.pmml.PairCountsDocument.PairCounts)1 MutableInteger (org.knime.core.util.MutableInteger)1