use of org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO in project drools by kiegroup.
the class KiePMMLMiningModelFactoryTest method getKiePMMLMiningModel.
@Test
public void getKiePMMLMiningModel() {
final CommonCompilationDTO<MiningModel> source = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, MINING_MODEL, new HasKnowledgeBuilderMock(KNOWLEDGE_BUILDER));
final MiningModelCompilationDTO compilationDTO = MiningModelCompilationDTO.fromCompilationDTO(source);
final KiePMMLMiningModel retrieved = KiePMMLMiningModelFactory.getKiePMMLMiningModel(compilationDTO);
assertNotNull(retrieved);
assertEquals(MINING_MODEL.getAlgorithmName(), retrieved.getAlgorithmName());
assertEquals(MINING_MODEL.isScorable(), retrieved.isScorable());
assertEquals(targetFieldName, retrieved.getTargetField());
}
use of org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO in project drools by kiegroup.
the class KiePMMLSegmentationFactoryTest method getSegmentationSourcesMap.
@Test
public void getSegmentationSourcesMap() {
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 = KiePMMLSegmentationFactory.getSegmentationSourcesMap(compilationDTO, nestedModels);
assertNotNull(retrieved);
int expectedNestedModels = MINING_MODEL.getSegmentation().getSegments().size();
assertEquals(expectedNestedModels, nestedModels.size());
}
use of org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO in project drools by kiegroup.
the class KiePMMLSegmentFactoryTest method getSegmentSourcesMapCompiled.
@Test
public void getSegmentSourcesMapCompiled() throws Exception {
final Segment segment = MINING_MODEL.getSegmentation().getSegments().get(0);
final List<KiePMMLModel> nestedModels = new ArrayList<>();
final String expectedNestedModelGeneratedClass = getExpectedNestedModelClass(segment);
final HasKnowledgeBuilderMock hasKnowledgeBuilderMock = new HasKnowledgeBuilderMock(KNOWLEDGE_BUILDER);
try {
hasKnowledgeBuilderMock.getClassLoader().loadClass(expectedNestedModelGeneratedClass);
fail("Expecting class not found: " + expectedNestedModelGeneratedClass);
} catch (Exception e) {
assertTrue(e instanceof ClassNotFoundException);
}
final CommonCompilationDTO<MiningModel> source = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, MINING_MODEL, hasKnowledgeBuilderMock);
final MiningModelCompilationDTO compilationDTO = MiningModelCompilationDTO.fromCompilationDTO(source);
final SegmentCompilationDTO segmentCompilationDTO = SegmentCompilationDTO.fromGeneratedPackageNameAndFields(compilationDTO, segment, compilationDTO.getFields());
final Map<String, String> retrieved = KiePMMLSegmentFactory.getSegmentSourcesMapCompiled(segmentCompilationDTO, nestedModels);
commonEvaluateNestedModels(nestedModels);
commonEvaluateMap(retrieved, segment);
hasKnowledgeBuilderMock.getClassLoader().loadClass(expectedNestedModelGeneratedClass);
}
use of org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO in project drools by kiegroup.
the class KiePMMLSegmentFactoryTest method getSegmentSourcesMap.
@Test
public void getSegmentSourcesMap() {
final Segment segment = MINING_MODEL.getSegmentation().getSegments().get(0);
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 SegmentCompilationDTO segmentCompilationDTO = SegmentCompilationDTO.fromGeneratedPackageNameAndFields(compilationDTO, segment, compilationDTO.getFields());
final Map<String, String> retrieved = KiePMMLSegmentFactory.getSegmentSourcesMap(segmentCompilationDTO, nestedModels);
commonEvaluateNestedModels(nestedModels);
commonEvaluateMap(retrieved, segment);
}
use of org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO 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);
}
}
Aggregations