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());
}
}
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);
}
}
}
Aggregations