use of org.kie.pmml.compiler.api.mocks.TestModel in project drools by kiegroup.
the class KiePMMLModelRetrieverTest method getFromCommonDataAndTransformationDictionaryAndModelWithProvider.
@Test
public void getFromCommonDataAndTransformationDictionaryAndModelWithProvider() throws Exception {
pmml = KiePMMLUtil.load(getFileInputStream(MULTIPLE_TARGETS_SOURCE), MULTIPLE_TARGETS_SOURCE);
TestModel model = new TestModel();
pmml.getModels().set(0, model);
final CommonCompilationDTO<TestModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, model, new HasClassLoaderMock());
final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModel(compilationDTO);
assertNotNull(retrieved);
assertTrue(retrieved.isPresent());
assertTrue(retrieved.get() instanceof KiePMMLTestingModel);
}
use of org.kie.pmml.compiler.api.mocks.TestModel 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.kie.pmml.compiler.api.mocks.TestModel 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