use of org.kie.pmml.commons.model.KiePMMLModel in project drools by kiegroup.
the class KiePMMLSegmentFactoryTest method getSegmentsSourcesMap.
@Test
public void getSegmentsSourcesMap() {
final List<Segment> segments = MINING_MODEL.getSegmentation().getSegments();
final List<KiePMMLModel> nestedModels = new ArrayList<>();
final CommonCompilationDTO<MiningModel> source = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, MINING_MODEL, new HasKnowledgeBuilderMock(KNOWLEDGE_BUILDER));
final MiningModelCompilationDTO compilationDTO = MiningModelCompilationDTO.fromCompilationDTO(source);
final Map<String, String> retrieved = KiePMMLSegmentFactory.getSegmentsSourcesMap(compilationDTO, nestedModels);
assertNotNull(retrieved);
commonEvaluateNestedModels(nestedModels);
for (Segment segment : segments) {
commonEvaluateMap(retrieved, segment);
}
}
use of org.kie.pmml.commons.model.KiePMMLModel in project drools by kiegroup.
the class KiePMMLMiningModelFactory method getKiePMMLMiningModel.
public static KiePMMLMiningModel getKiePMMLMiningModel(final MiningModelCompilationDTO compilationDTO) {
logger.debug("getKiePMMLMiningModel {}", compilationDTO.getModel());
final List<KiePMMLModel> nestedModels = new ArrayList<>();
Map<String, String> sourcesMap = getKiePMMLMiningModelSourcesMapCompiled(compilationDTO, nestedModels);
try {
Class<?> kiePMMLMiningModel = compilationDTO.compileAndLoadClass(sourcesMap);
return (KiePMMLMiningModel) kiePMMLMiningModel.newInstance();
} catch (Exception e) {
throw new KiePMMLException(e);
}
}
use of org.kie.pmml.commons.model.KiePMMLModel in project drools by kiegroup.
the class KiePMMLSegmentFactory method getSegmentSourcesMapCompiled.
public static Map<String, String> getSegmentSourcesMapCompiled(final SegmentCompilationDTO segmentCompilationDTO, final List<KiePMMLModel> nestedModels) {
logger.debug(GET_SEGMENT, segmentCompilationDTO.getSegment());
final KiePMMLModel nestedModel = getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiled(segmentCompilationDTO).orElseThrow(() -> new KiePMMLException("Failed to get the KiePMMLModel for segment " + segmentCompilationDTO.getModel().getModelName()));
final Map<String, String> toReturn = getSegmentSourcesMapCommon(segmentCompilationDTO, nestedModels, nestedModel);
segmentCompilationDTO.addFields(getFieldsFromModel(segmentCompilationDTO.getModel()));
return toReturn;
}
use of org.kie.pmml.commons.model.KiePMMLModel in project drools by kiegroup.
the class KiePMMLSegmentFactory method getSegmentSourcesMap.
public static Map<String, String> getSegmentSourcesMap(final SegmentCompilationDTO segmentCompilationDTO, final List<KiePMMLModel> nestedModels) {
logger.debug(GET_SEGMENT, segmentCompilationDTO.getSegment());
final KiePMMLModel nestedModel = getFromCommonDataAndTransformationDictionaryAndModelWithSources(segmentCompilationDTO).orElseThrow(() -> new KiePMMLException("Failed to get the KiePMMLModel for segment " + segmentCompilationDTO.getModel().getModelName()));
final Map<String, String> toReturn = getSegmentSourcesMapCommon(segmentCompilationDTO, nestedModels, nestedModel);
segmentCompilationDTO.addFields(getFieldsFromModel(segmentCompilationDTO.getModel()));
return toReturn;
}
use of org.kie.pmml.commons.model.KiePMMLModel in project drools by kiegroup.
the class KiePMMLMiningModelFactoryTest method getKiePMMLMiningModelSourcesMap.
@Test
public void getKiePMMLMiningModelSourcesMap() {
final List<KiePMMLModel> nestedModels = new ArrayList<>();
final CommonCompilationDTO<MiningModel> source = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, MINING_MODEL, new HasKnowledgeBuilderMock(KNOWLEDGE_BUILDER));
final MiningModelCompilationDTO compilationDTO = MiningModelCompilationDTO.fromCompilationDTO(source);
final Map<String, String> retrieved = KiePMMLMiningModelFactory.getKiePMMLMiningModelSourcesMap(compilationDTO, nestedModels);
assertNotNull(retrieved);
int expectedNestedModels = MINING_MODEL.getSegmentation().getSegments().size();
assertEquals(expectedNestedModels, nestedModels.size());
}
Aggregations