Search in sources :

Example 1 with KiePMMLRegressionModel

use of org.kie.pmml.models.regression.model.KiePMMLRegressionModel in project drools by kiegroup.

the class RegressionModelImplementationProviderTest method getKiePMMLModel.

@Test
public void getKiePMMLModel() throws Exception {
    final PMML pmml = TestUtils.loadFromFile(SOURCE_1);
    assertNotNull(pmml);
    assertEquals(1, pmml.getModels().size());
    assertTrue(pmml.getModels().get(0) instanceof RegressionModel);
    RegressionModel regressionModel = (RegressionModel) pmml.getModels().get(0);
    final CommonCompilationDTO<RegressionModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, regressionModel, new HasClassLoaderMock());
    final KiePMMLRegressionModel retrieved = PROVIDER.getKiePMMLModel(compilationDTO);
    assertNotNull(retrieved);
    assertTrue(retrieved instanceof Serializable);
}
Also used : Serializable(java.io.Serializable) KiePMMLRegressionModel(org.kie.pmml.models.regression.model.KiePMMLRegressionModel) PMML(org.dmg.pmml.PMML) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) RegressionModel(org.dmg.pmml.regression.RegressionModel) KiePMMLRegressionModel(org.kie.pmml.models.regression.model.KiePMMLRegressionModel) Test(org.junit.Test)

Example 2 with KiePMMLRegressionModel

use of org.kie.pmml.models.regression.model.KiePMMLRegressionModel in project drools by kiegroup.

the class KiePMMLRegressionModelFactoryTest method getKiePMMLRegressionModelClasses.

@Test
public void getKiePMMLRegressionModelClasses() throws IOException, IllegalAccessException, InstantiationException {
    final CompilationDTO<RegressionModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, regressionModel, new HasClassLoaderMock());
    KiePMMLRegressionModel retrieved = KiePMMLRegressionModelFactory.getKiePMMLRegressionModelClasses(RegressionCompilationDTO.fromCompilationDTO(compilationDTO));
    assertNotNull(retrieved);
    assertEquals(regressionModel.getModelName(), retrieved.getName());
    assertEquals(MINING_FUNCTION.byName(regressionModel.getMiningFunction().value()), retrieved.getMiningFunction());
    assertEquals(miningFields.get(0).getName().getValue(), retrieved.getTargetField());
    final AbstractKiePMMLTable regressionTable = retrieved.getRegressionTable();
    assertNotNull(regressionTable);
    assertTrue(regressionTable instanceof KiePMMLClassificationTable);
    evaluateCategoricalRegressionTable((KiePMMLClassificationTable) regressionTable);
}
Also used : KiePMMLRegressionModel(org.kie.pmml.models.regression.model.KiePMMLRegressionModel) AbstractKiePMMLTable(org.kie.pmml.models.regression.model.AbstractKiePMMLTable) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) KiePMMLClassificationTable(org.kie.pmml.models.regression.model.KiePMMLClassificationTable) PMMLModelTestUtils.getRegressionModel(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRegressionModel) RegressionModel(org.dmg.pmml.regression.RegressionModel) KiePMMLRegressionModel(org.kie.pmml.models.regression.model.KiePMMLRegressionModel) Test(org.junit.Test)

Aggregations

RegressionModel (org.dmg.pmml.regression.RegressionModel)2 Test (org.junit.Test)2 HasClassLoaderMock (org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock)2 KiePMMLRegressionModel (org.kie.pmml.models.regression.model.KiePMMLRegressionModel)2 Serializable (java.io.Serializable)1 PMML (org.dmg.pmml.PMML)1 PMMLModelTestUtils.getRegressionModel (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRegressionModel)1 AbstractKiePMMLTable (org.kie.pmml.models.regression.model.AbstractKiePMMLTable)1 KiePMMLClassificationTable (org.kie.pmml.models.regression.model.KiePMMLClassificationTable)1