Search in sources :

Example 6 with MiningModelCompilationDTO

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());
}
Also used : HasKnowledgeBuilderMock(org.kie.pmml.models.mining.compiler.HasKnowledgeBuilderMock) KiePMMLMiningModel(org.kie.pmml.models.mining.model.KiePMMLMiningModel) MiningModel(org.dmg.pmml.mining.MiningModel) KiePMMLMiningModel(org.kie.pmml.models.mining.model.KiePMMLMiningModel) MiningModelCompilationDTO(org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO) Test(org.junit.Test)

Example 7 with MiningModelCompilationDTO

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());
}
Also used : HasKnowledgeBuilderMock(org.kie.pmml.models.mining.compiler.HasKnowledgeBuilderMock) MiningModel(org.dmg.pmml.mining.MiningModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) ArrayList(java.util.ArrayList) MiningModelCompilationDTO(org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO) Test(org.junit.Test)

Example 8 with MiningModelCompilationDTO

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);
}
Also used : HasKnowledgeBuilderMock(org.kie.pmml.models.mining.compiler.HasKnowledgeBuilderMock) ArrayList(java.util.ArrayList) SegmentCompilationDTO(org.kie.pmml.models.mining.compiler.dto.SegmentCompilationDTO) Segment(org.dmg.pmml.mining.Segment) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) SAXException(org.xml.sax.SAXException) MiningModel(org.dmg.pmml.mining.MiningModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) MiningModelCompilationDTO(org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO) Test(org.junit.Test)

Example 9 with MiningModelCompilationDTO

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);
}
Also used : HasKnowledgeBuilderMock(org.kie.pmml.models.mining.compiler.HasKnowledgeBuilderMock) MiningModel(org.dmg.pmml.mining.MiningModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) ArrayList(java.util.ArrayList) SegmentCompilationDTO(org.kie.pmml.models.mining.compiler.dto.SegmentCompilationDTO) MiningModelCompilationDTO(org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO) Segment(org.dmg.pmml.mining.Segment) Test(org.junit.Test)

Example 10 with MiningModelCompilationDTO

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);
    }
}
Also used : HasKnowledgeBuilderMock(org.kie.pmml.models.mining.compiler.HasKnowledgeBuilderMock) MiningModel(org.dmg.pmml.mining.MiningModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) ArrayList(java.util.ArrayList) MiningModelCompilationDTO(org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO) Segment(org.dmg.pmml.mining.Segment) Test(org.junit.Test)

Aggregations

MiningModel (org.dmg.pmml.mining.MiningModel)10 Test (org.junit.Test)10 MiningModelCompilationDTO (org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO)10 HasKnowledgeBuilderMock (org.kie.pmml.models.mining.compiler.HasKnowledgeBuilderMock)9 ArrayList (java.util.ArrayList)7 KiePMMLModel (org.kie.pmml.commons.model.KiePMMLModel)7 Segment (org.dmg.pmml.mining.Segment)4 KiePMMLMiningModel (org.kie.pmml.models.mining.model.KiePMMLMiningModel)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 JAXBException (javax.xml.bind.JAXBException)3 SegmentCompilationDTO (org.kie.pmml.models.mining.compiler.dto.SegmentCompilationDTO)3 SAXException (org.xml.sax.SAXException)3 StaticJavaParser.parseClassOrInterfaceType (com.github.javaparser.StaticJavaParser.parseClassOrInterfaceType)2 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)2 ConstructorDeclaration (com.github.javaparser.ast.body.ConstructorDeclaration)2 Expression (com.github.javaparser.ast.expr.Expression)2 NameExpr (com.github.javaparser.ast.expr.NameExpr)2 ObjectCreationExpr (com.github.javaparser.ast.expr.ObjectCreationExpr)2 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)2