use of org.knime.core.node.port.pmml.preproc.DerivedFieldMapper in project knime-core by knime.
the class AbstractMetaDataMapper method createMetaDataMapper.
static AbstractMetaDataMapper<?> createMetaDataMapper(final DataTableSpec tableSpec) {
DataColumnSpec targetCol = tableSpec.getColumnSpec(tableSpec.getNumColumns() - 1);
DataType targetType = targetCol.getType();
// we need the pmml to instantiate the actual mapper which we don't have at this point
DerivedFieldMapper dummyDerivedFieldMapper = new DerivedFieldMapper(new DerivedFieldDocument.DerivedField[] {});
if (targetType.isCompatible(StringValue.class)) {
return new ClassificationMetaDataMapper(tableSpec, targetCol.getName(), dummyDerivedFieldMapper);
} else if (targetType.isCompatible(DoubleValue.class)) {
return new RegressionMetaDataMapper(tableSpec, targetCol.getName(), dummyDerivedFieldMapper);
}
throw new IllegalArgumentException("The target column \"" + targetCol + "\" is not numeric or nominal.");
}
use of org.knime.core.node.port.pmml.preproc.DerivedFieldMapper in project knime-core by knime.
the class PMMLRuleTranslator method initializeFrom.
/**
* {@inheritDoc}
*/
@Override
public void initializeFrom(final PMMLDocument pmmlDoc) {
m_nameMapper = new DerivedFieldMapper(pmmlDoc);
List<RuleSetModel> models = pmmlDoc.getPMML().getRuleSetModelList();
if (models.size() == 0) {
throw new IllegalArgumentException("No treemodel provided.");
}
m_originalRuleModel = models.get(0);
initDataDictionary(pmmlDoc);
m_rules = parseRulesFromModel(m_originalRuleModel);
MININGFUNCTION.Enum functionName = m_originalRuleModel.getFunctionName();
assert functionName == MININGFUNCTION.CLASSIFICATION : functionName;
m_isScorable = m_originalRuleModel.getIsScorable();
RuleSet ruleSet = m_originalRuleModel.getRuleSet();
m_selectionMethodList = ruleSet.getRuleSelectionMethodList();
m_defaultScore = ruleSet.isSetDefaultScore() ? ruleSet.getDefaultScore() : null;
m_defaultConfidence = ruleSet.isSetDefaultConfidence() ? ruleSet.getDefaultConfidence() : Double.NaN;
m_recordCount = ruleSet.isSetRecordCount() ? ruleSet.getRecordCount() : Double.NaN;
m_nbCorrect = ruleSet.isSetNbCorrect() ? ruleSet.getNbCorrect() : Double.NaN;
}
Aggregations