use of org.dmg.pmml.OutputField in project drools by kiegroup.
the class ModelUtilsTest method convertToKieOutputField.
@Test
public void convertToKieOutputField() {
final OutputField toConvert = getRandomOutputField();
org.kie.pmml.api.models.OutputField retrieved = ModelUtils.convertToKieOutputField(toConvert, null);
assertNotNull(retrieved);
assertEquals(toConvert.getName().getValue(), retrieved.getName());
OP_TYPE expectedOpType = OP_TYPE.byName(toConvert.getOpType().value());
assertEquals(expectedOpType, retrieved.getOpType());
DATA_TYPE expectedDataType = DATA_TYPE.byName(toConvert.getDataType().value());
assertEquals(expectedDataType, retrieved.getDataType());
assertEquals(toConvert.getTargetField().getValue(), retrieved.getTargetField());
RESULT_FEATURE expectedResultFeature = RESULT_FEATURE.byName(toConvert.getResultFeature().value());
assertEquals(expectedResultFeature, retrieved.getResultFeature());
toConvert.setOpType(null);
toConvert.setTargetField(null);
retrieved = ModelUtils.convertToKieOutputField(toConvert, null);
assertNull(retrieved.getOpType());
assertNull(retrieved.getTargetField());
}
use of org.dmg.pmml.OutputField in project drools by kiegroup.
the class PMMLModelTestUtils method getRandomMiningModel.
public static MiningModel getRandomMiningModel(DataDictionary dataDictionary) {
MiningModel toReturn = new MiningModel();
List<DataField> dataFields = dataDictionary.getDataFields();
MiningSchema miningSchema = new MiningSchema();
IntStream.range(0, dataFields.size() - 1).forEach(i -> {
DataField dataField = dataFields.get(i);
MiningField miningField = new MiningField();
miningField.setName(dataField.getName());
miningField.setUsageType(MiningField.UsageType.ACTIVE);
miningSchema.addMiningFields(miningField);
});
DataField lastDataField = dataFields.get(dataFields.size() - 1);
MiningField predictedMiningField = new MiningField();
predictedMiningField.setName(lastDataField.getName());
predictedMiningField.setUsageType(MiningField.UsageType.PREDICTED);
miningSchema.addMiningFields(predictedMiningField);
Output output = new Output();
OutputField outputField = new OutputField();
outputField.setName(FieldName.create("OUTPUT_" + lastDataField.getName().getValue()));
outputField.setDataType(lastDataField.getDataType());
outputField.setOpType(getRandomOpType());
toReturn.setModelName(RandomStringUtils.random(6, true, false));
toReturn.setMiningSchema(miningSchema);
toReturn.setOutput(output);
TestModel testModel = getRandomTestModel(dataDictionary);
Segment segment = new Segment();
segment.setModel(testModel);
Segmentation segmentation = new Segmentation();
segmentation.addSegments(segment);
toReturn.setSegmentation(segmentation);
return toReturn;
}
use of org.dmg.pmml.OutputField in project drools by kiegroup.
the class PMMLModelTestUtils method getRandomTestModel.
public static TestModel getRandomTestModel(DataDictionary dataDictionary) {
TestModel toReturn = new TestModel();
List<DataField> dataFields = dataDictionary.getDataFields();
MiningSchema miningSchema = new MiningSchema();
IntStream.range(0, dataFields.size() - 1).forEach(i -> {
DataField dataField = dataFields.get(i);
MiningField miningField = new MiningField();
miningField.setName(dataField.getName());
miningField.setUsageType(MiningField.UsageType.ACTIVE);
miningSchema.addMiningFields(miningField);
});
DataField lastDataField = dataFields.get(dataFields.size() - 1);
MiningField predictedMiningField = new MiningField();
predictedMiningField.setName(lastDataField.getName());
predictedMiningField.setUsageType(MiningField.UsageType.PREDICTED);
miningSchema.addMiningFields(predictedMiningField);
Output output = new Output();
OutputField outputField = new OutputField();
outputField.setName(FieldName.create("OUTPUT_" + lastDataField.getName().getValue()));
outputField.setDataType(lastDataField.getDataType());
outputField.setOpType(getRandomOpType());
toReturn.setModelName(RandomStringUtils.random(6, true, false));
toReturn.setMiningSchema(miningSchema);
toReturn.setOutput(output);
return toReturn;
}
Aggregations