use of org.kie.dmg.pmml.pmml_4_2.descr.DataDictionary in project drools by kiegroup.
the class AbstractModel method getOutputFields.
@Override
public List<PMMLOutputField> getOutputFields() {
List<PMMLOutputField> fields = new ArrayList<>();
for (String key : outputFieldMap.keySet()) {
OutputField of = outputFieldMap.get(key);
fields.add(new PMMLOutputField(of, null, this.getModelId()));
}
Map<String, MiningField> includeFromMining = getFilteredMiningFieldMap(true, FIELDUSAGETYPE.PREDICTED, FIELDUSAGETYPE.TARGET);
Map<String, PMMLDataField> dataDictionary = getOwner().getDataDictionaryMap();
if (includeFromMining != null && !includeFromMining.isEmpty()) {
for (String key : includeFromMining.keySet()) {
MiningField field = includeFromMining.get(key);
PMMLDataField df = dataDictionary.get(key);
fields.add(new PMMLOutputField(field, df.getRawDataField(), this.getModelId()));
}
}
return fields;
}
use of org.kie.dmg.pmml.pmml_4_2.descr.DataDictionary 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.DataDictionary in project drools by kiegroup.
the class PMML4Compiler method buildResourceFromSegment.
protected PMMLResource buildResourceFromSegment(PMML pmml_origin, MiningSegment segment, ClassLoader classLoader, KieModuleModel module) {
PMML pmml = new PMML();
DataDictionary dd = pmml_origin.getDataDictionary();
pmml.setDataDictionary(dd);
pmml.setHeader(pmml_origin.getHeader());
pmml.getAssociationModelsAndBaselineModelsAndClusteringModels().add(segment.getModel().getRawModel());
addMissingFieldDefinition(pmml, segment.getOwner(), segment);
// PMML4Helper.pmmlDefaultPackageName()+".mining.segment_"+segment.getSegmentId());
helper.setPack(segment.getModel().getModelPackageName());
String rules = this.compile(pmml, classLoader);
KieBaseModel kbModel = module.newKieBaseModel(segment.getOwner().getOwner().getModelId() + "_" + segment.getOwner().getSegmentationId() + "_SEGMENT_" + segment.getSegmentId());
kbModel.addPackage(helper.getPack()).setDefault(false).setEventProcessingMode(EventProcessingOption.CLOUD);
KieSessionModel ksm = kbModel.newKieSessionModel("SEGMENT_" + segment.getSegmentId());
ksm.setDefault(true);
PMMLResource resource = new PMMLResource(helper.getPack());
resource.setKieBaseModel(kbModel);
resource.addRules(segment.getModel().getModelId(), rules);
return resource;
}
use of org.kie.dmg.pmml.pmml_4_2.descr.DataDictionary in project drools by kiegroup.
the class AbstractModel method getMiningFields.
@Override
public List<PMMLMiningField> getMiningFields() {
List<PMMLMiningField> fields = new ArrayList<>();
Map<String, MiningField> excludesTargetMap = getFilteredMiningFieldMap(false, FIELDUSAGETYPE.TARGET);
Map<String, PMMLDataField> dataDictionary = getOwner().getDataDictionaryMap();
for (String key : excludesTargetMap.keySet()) {
PMMLDataField df = dataDictionary.get(key);
MiningField mf = miningFieldMap.get(key);
if (df != null) {
fields.add(new PMMLMiningField(mf, df.getRawDataField(), this.getModelId(), true));
} else {
PMMLMiningField fld = new PMMLMiningField(mf, this.getModelId());
if (this.getParentModel() != null) {
PMML4Model ultimateParentModel = this.getParentModel();
if (ultimateParentModel instanceof Miningmodel) {
while (ultimateParentModel.getParentModel() != null) {
ultimateParentModel = ultimateParentModel.getParentModel();
}
PMMLOutputField ofld = ((Miningmodel) ultimateParentModel).findOutputField(fld.getName());
if (ofld != null) {
fld.setType(ofld.getType());
fields.add(fld);
}
}
}
}
}
return fields;
}
use of org.kie.dmg.pmml.pmml_4_2.descr.DataDictionary in project drools by kiegroup.
the class Miningmodel method initChildModels.
protected void initChildModels() {
childModels = new HashMap<>();
Iterator<Serializable> extenIter = rawModel.getExtensionsAndMiningSchemasAndOutputs().iterator();
segmentation = null;
while (extenIter.hasNext() && segmentation == null) {
Object obj = extenIter.next();
if (obj instanceof Segmentation) {
segmentation = new MiningSegmentation(this, (Segmentation) obj);
}
}
if (segmentation != null) {
List<MiningSegment> segments = segmentation.getMiningSegments();
DataDictionary dd = this.getDataDictionary();
for (MiningSegment seg : segmentation.getMiningSegments()) {
childModels.put(seg.getModel().getModelId(), seg.getModel());
}
}
}
Aggregations