Search in sources :

Example 1 with TargetValueStats

use of org.dmg.pmml.TargetValueStatsDocument.TargetValueStats in project knime-core by knime.

the class AttributeModel method loadModel.

/**
 * @param bayesInput the <code>BayesInput</code> object to read from
 * @return the attribute model for the given <code>Config</code> object
 * @throws InvalidSettingsException if the settings are invalid
 */
static AttributeModel loadModel(final BayesInput bayesInput) throws InvalidSettingsException {
    final String attrName = bayesInput.getFieldName();
    final Map<String, String> extensionMap = PMMLNaiveBayesModelTranslator.convertToMap(bayesInput.getExtensionList());
    boolean skipMissing = true;
    int noOfMissingVals = 0;
    if (extensionMap.containsKey(NO_OF_MISSING_VALUES)) {
        skipMissing = false;
        noOfMissingVals = PMMLNaiveBayesModelTranslator.getIntExtension(extensionMap, NO_OF_MISSING_VALUES);
    }
    final List<PairCounts> pairCounts = bayesInput.getPairCountsList();
    final AttributeModel model;
    if (pairCounts != null && !pairCounts.isEmpty()) {
        model = new NominalAttributeModel(attrName, noOfMissingVals, skipMissing, bayesInput);
    } else {
        final TargetValueStats stats = bayesInput.getTargetValueStats();
        if (stats != null) {
            model = new NumericalAttributeModel(attrName, skipMissing, noOfMissingVals, bayesInput);
        } else {
            throw new InvalidSettingsException("Invalid model type for field " + bayesInput.getFieldName());
        }
    }
    return model;
}
Also used : PairCounts(org.dmg.pmml.PairCountsDocument.PairCounts) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) TargetValueStats(org.dmg.pmml.TargetValueStatsDocument.TargetValueStats)

Example 2 with TargetValueStats

use of org.dmg.pmml.TargetValueStatsDocument.TargetValueStats in project knime-core by knime.

the class NumericalAttributeModel method exportToPMMLInternal.

/**
 * {@inheritDoc}
 */
@Override
void exportToPMMLInternal(final BayesInput bayesInput) {
    final TargetValueStats targetValueStats = bayesInput.addNewTargetValueStats();
    for (final NumericalClassValue classVal : m_classValues.values()) {
        final TargetValueStat targetValueStat = targetValueStats.addNewTargetValueStat();
        classVal.exportToPMML(targetValueStat);
    }
}
Also used : TargetValueStats(org.dmg.pmml.TargetValueStatsDocument.TargetValueStats) TargetValueStat(org.dmg.pmml.TargetValueStatDocument.TargetValueStat)

Aggregations

TargetValueStats (org.dmg.pmml.TargetValueStatsDocument.TargetValueStats)2 PairCounts (org.dmg.pmml.PairCountsDocument.PairCounts)1 TargetValueStat (org.dmg.pmml.TargetValueStatDocument.TargetValueStat)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1