Search in sources :

Example 16 with KiePMMLModel

use of org.kie.pmml.commons.model.KiePMMLModel 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);
}
Also used : KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) KiePMMLTestingModel(org.kie.pmml.commons.testingutility.KiePMMLTestingModel) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) PMMLModelTestUtils.getPMMLWithMiningRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithMiningRandomTestModel) PMMLModelTestUtils.getPMMLWithRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithRandomTestModel) TestModel(org.kie.pmml.compiler.api.mocks.TestModel) Test(org.junit.Test)

Example 17 with KiePMMLModel

use of org.kie.pmml.commons.model.KiePMMLModel in project drools by kiegroup.

the class KiePMMLModelRetrieverTest method getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiledWithoutProvider.

@Test
public void getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiledWithoutProvider() throws Exception {
    pmml = KiePMMLUtil.load(getFileInputStream(MINING_MODEL_WITH_NESTED_REFERS_SOURCE), MINING_MODEL_WITH_NESTED_REFERS_SOURCE);
    MiningModel parentModel = (MiningModel) pmml.getModels().get(0);
    Model model = parentModel.getSegmentation().getSegments().get(0).getModel();
    final CommonCompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, model, new HasClassLoaderMock());
    final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiled(compilationDTO);
    assertNotNull(retrieved);
    assertFalse(retrieved.isPresent());
}
Also used : MiningModel(org.dmg.pmml.mining.MiningModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) PMMLModelTestUtils.getPMMLWithMiningRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithMiningRandomTestModel) Model(org.dmg.pmml.Model) PMMLModelTestUtils.getPMMLWithRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithRandomTestModel) KiePMMLTestingModel(org.kie.pmml.commons.testingutility.KiePMMLTestingModel) TestModel(org.kie.pmml.compiler.api.mocks.TestModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) KiePMMLModelRetriever.getFromCommonDataAndTransformationDictionaryAndModel(org.kie.pmml.compiler.commons.implementations.KiePMMLModelRetriever.getFromCommonDataAndTransformationDictionaryAndModel) MiningModel(org.dmg.pmml.mining.MiningModel) CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 18 with KiePMMLModel

use of org.kie.pmml.commons.model.KiePMMLModel in project drools by kiegroup.

the class KiePMMLModelRetrieverTest method getFromDataDictionaryAndModelWithSourcesWithoutProvider.

@Test
public void getFromDataDictionaryAndModelWithSourcesWithoutProvider() throws Exception {
    pmml = KiePMMLUtil.load(getFileInputStream(ONE_MINING_TARGET_SOURCE), ONE_MINING_TARGET_SOURCE);
    final CommonCompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, pmml.getModels().get(0), new HasClassLoaderMock());
    final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModelWithSources(compilationDTO);
    assertNotNull(retrieved);
    assertFalse(retrieved.isPresent());
}
Also used : KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 19 with KiePMMLModel

use of org.kie.pmml.commons.model.KiePMMLModel in project drools by kiegroup.

the class KiePMMLModelRetrieverTest method getFromCommonDataAndTransformationDictionaryAndModelWithoutProvider.

@Test
public void getFromCommonDataAndTransformationDictionaryAndModelWithoutProvider() throws Exception {
    pmml = KiePMMLUtil.load(getFileInputStream(ONE_MINING_TARGET_SOURCE), ONE_MINING_TARGET_SOURCE);
    final CommonCompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, pmml.getModels().get(0), new HasClassLoaderMock());
    final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModel(compilationDTO);
    assertNotNull(retrieved);
    assertFalse(retrieved.isPresent());
}
Also used : KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Example 20 with KiePMMLModel

use of org.kie.pmml.commons.model.KiePMMLModel in project drools by kiegroup.

the class KiePMMLModelRetrieverTest method getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiledWithProvider.

@Test
public void getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiledWithProvider() throws Exception {
    pmml = getPMMLWithMiningRandomTestModel();
    MiningModel parentModel = (MiningModel) pmml.getModels().get(0);
    Model model = parentModel.getSegmentation().getSegments().get(0).getModel();
    final CommonCompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, model, new HasClassLoaderMock());
    final Optional<KiePMMLModel> retrieved = getFromCommonDataAndTransformationDictionaryAndModelWithSourcesCompiled(compilationDTO);
    assertNotNull(retrieved);
    assertTrue(retrieved.isPresent());
}
Also used : MiningModel(org.dmg.pmml.mining.MiningModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) PMMLModelTestUtils.getPMMLWithMiningRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithMiningRandomTestModel) Model(org.dmg.pmml.Model) PMMLModelTestUtils.getPMMLWithRandomTestModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithRandomTestModel) KiePMMLTestingModel(org.kie.pmml.commons.testingutility.KiePMMLTestingModel) TestModel(org.kie.pmml.compiler.api.mocks.TestModel) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) KiePMMLModelRetriever.getFromCommonDataAndTransformationDictionaryAndModel(org.kie.pmml.compiler.commons.implementations.KiePMMLModelRetriever.getFromCommonDataAndTransformationDictionaryAndModel) MiningModel(org.dmg.pmml.mining.MiningModel) CommonCompilationDTO(org.kie.pmml.compiler.api.dto.CommonCompilationDTO) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) Test(org.junit.Test)

Aggregations

KiePMMLModel (org.kie.pmml.commons.model.KiePMMLModel)37 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)17 MiningModel (org.dmg.pmml.mining.MiningModel)9 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)9 KiePMMLTestingModel (org.kie.pmml.commons.testingutility.KiePMMLTestingModel)8 CommonCompilationDTO (org.kie.pmml.compiler.api.dto.CommonCompilationDTO)7 HasClassLoaderMock (org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock)7 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 HasKnowledgeBuilderMock (org.kie.pmml.models.mining.compiler.HasKnowledgeBuilderMock)6 MiningModelCompilationDTO (org.kie.pmml.models.mining.compiler.dto.MiningModelCompilationDTO)6 HasSourcesMap (org.kie.pmml.commons.model.HasSourcesMap)5 File (java.io.File)4 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)4 Assert.assertEquals (org.junit.Assert.assertEquals)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 MINING_FUNCTION (org.kie.pmml.api.enums.MINING_FUNCTION)4