use of org.kie.dmg.pmml.pmml_4_2.descr.DataField in project drools by kiegroup.
the class PMML4UnitImpl method initDataDictionaryMap.
/**
* Initializes the internal structure that holds data dictionary information.
* This initializer should be called prior to any other initializers, since
* many other structures may have a dependency on the data dictionary.
*/
private void initDataDictionaryMap() {
DataDictionary dd = rawPmml.getDataDictionary();
if (dd != null) {
dataDictionaryMap = new HashMap<>();
for (DataField dataField : dd.getDataFields()) {
PMMLDataField df = new PMMLDataField(dataField);
dataDictionaryMap.put(df.getName(), df);
}
} else {
throw new IllegalStateException("BRMS-PMML requires a data dictionary section in the definition file");
}
}
use of org.kie.dmg.pmml.pmml_4_2.descr.DataField in project drools by kiegroup.
the class PMML4Compiler method addMissingFieldDefinition.
private void addMissingFieldDefinition(PMML pmml, MiningSegmentation msm, MiningSegment seg) {
// get the list of models that may contain the field definition
List<PMML4Model> models = msm.getMiningSegments().stream().filter(s -> s != seg && s.getSegmentIndex() < seg.getSegmentIndex()).map(iseg -> {
return iseg.getModel();
}).collect(Collectors.toList());
seg.getModel().getMiningFields().stream().filter(mf -> !mf.isInDictionary()).forEach(pmf -> {
String fldName = pmf.getName();
boolean fieldAdded = false;
for (Iterator<PMML4Model> iter = models.iterator(); iter.hasNext() && !fieldAdded; ) {
PMML4Model mdl = iter.next();
PMMLOutputField outfield = mdl.findOutputField(fldName);
PMMLMiningField target = (outfield != null && outfield.getTargetField() != null) ? mdl.findMiningField(outfield.getTargetField()) : null;
if (outfield != null) {
DataField e = null;
if (outfield.getRawDataField() != null && outfield.getRawDataField().getDataType() != null) {
e = outfield.getRawDataField();
} else if (target != null) {
e = target.getRawDataField();
}
if (e != null) {
e.setName(fldName);
pmml.getDataDictionary().getDataFields().add(e);
BigInteger bi = pmml.getDataDictionary().getNumberOfFields();
pmml.getDataDictionary().setNumberOfFields(bi.add(BigInteger.ONE));
fieldAdded = true;
}
}
}
});
}
Aggregations