use of org.kie.dmg.pmml.pmml_4_2.descr.OutputField in project drools by kiegroup.
the class ExternalObjectModelTest method testPMMLCustomOutput.
@Test
public void testPMMLCustomOutput() throws Exception {
PMML pmmlDocument = null;
String drl = null;
if (scorecardCompiler.compileFromExcel(PMMLDocumentTest.class.getResourceAsStream("/scoremodel_externalmodel.xls"))) {
pmmlDocument = scorecardCompiler.getPMMLDocument();
assertNotNull(pmmlDocument);
PMML4Compiler.dumpModel(pmmlDocument, System.out);
drl = scorecardCompiler.getDRL();
assertTrue(drl != null && !drl.isEmpty());
// System.out.println(drl);
} else {
fail("failed to parse scoremodel Excel.");
}
for (Object serializable : pmmlDocument.getAssociationModelsAndBaselineModelsAndClusteringModels()) {
if (serializable instanceof Scorecard) {
Scorecard scorecard = (Scorecard) serializable;
for (Object obj : scorecard.getExtensionsAndCharacteristicsAndMiningSchemas()) {
if (obj instanceof Output) {
Output output = (Output) obj;
final List<OutputField> outputFields = output.getOutputFields();
assertEquals(1, outputFields.size());
final OutputField outputField = outputFields.get(0);
assertNotNull(outputField);
assertEquals("totalScore", outputField.getName());
assertEquals("Final Score", outputField.getDisplayName());
assertEquals("double", outputField.getDataType().value());
assertEquals("predictedValue", outputField.getFeature().value());
final Extension extension = ScorecardPMMLUtils.getExtension(outputField.getExtensions(), PMMLExtensionNames.EXTERNAL_CLASS);
assertNotNull(extension);
assertEquals("org.drools.scorecards.example.Applicant", extension.getValue());
return;
}
}
}
}
fail();
}
use of org.kie.dmg.pmml.pmml_4_2.descr.OutputField 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.OutputField in project drools by kiegroup.
the class AbstractModel method initOutputFieldMap.
protected void initOutputFieldMap() {
Output output = getOutput();
outputFieldMap = new HashMap<>();
if (output != null) {
for (OutputField field : output.getOutputFields()) {
outputFieldMap.put(field.getName(), field);
}
}
}
Aggregations