Search in sources :

Example 1 with KiePMMLClusteringModel

use of org.kie.pmml.models.clustering.model.KiePMMLClusteringModel in project drools by kiegroup.

the class ClusteringModelImplementationProviderTest method getKiePMMLModel.

@Test
public void getKiePMMLModel() throws Exception {
    PMML pmml = TestUtils.loadFromFile(SOURCE_FILE);
    ClusteringModel model = getModel(pmml);
    final CommonCompilationDTO<ClusteringModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, model, new HasClassLoaderMock());
    KiePMMLClusteringModel retrieved = PROVIDER.getKiePMMLModel(compilationDTO);
    assertNotNull(retrieved);
    assertTrue(retrieved instanceof Serializable);
}
Also used : Serializable(java.io.Serializable) PMML(org.dmg.pmml.PMML) KiePMMLClusteringModel(org.kie.pmml.models.clustering.model.KiePMMLClusteringModel) HasClassLoaderMock(org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock) KiePMMLClusteringModel(org.kie.pmml.models.clustering.model.KiePMMLClusteringModel) ClusteringModel(org.dmg.pmml.clustering.ClusteringModel) Test(org.junit.Test)

Example 2 with KiePMMLClusteringModel

use of org.kie.pmml.models.clustering.model.KiePMMLClusteringModel in project drools by kiegroup.

the class KiePMMLClusteringModelFactory method getKiePMMLClusteringModel.

public static KiePMMLClusteringModel getKiePMMLClusteringModel(final CompilationDTO<ClusteringModel> compilationDTO) {
    logger.trace("getKiePMMLClusteringModel {}", compilationDTO);
    Map<String, String> sourcesMap = getKiePMMLClusteringModelSourcesMap(compilationDTO);
    try {
        Class<?> clusteringModelClass = compilationDTO.compileAndLoadClass(sourcesMap);
        return (KiePMMLClusteringModel) clusteringModelClass.getDeclaredConstructor().newInstance();
    } catch (Exception e) {
        throw new KiePMMLException(e);
    }
}
Also used : KiePMMLClusteringModel(org.kie.pmml.models.clustering.model.KiePMMLClusteringModel) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) KiePMMLInternalException(org.kie.pmml.api.exceptions.KiePMMLInternalException) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException)

Aggregations

KiePMMLClusteringModel (org.kie.pmml.models.clustering.model.KiePMMLClusteringModel)2 Serializable (java.io.Serializable)1 PMML (org.dmg.pmml.PMML)1 ClusteringModel (org.dmg.pmml.clustering.ClusteringModel)1 Test (org.junit.Test)1 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)1 KiePMMLInternalException (org.kie.pmml.api.exceptions.KiePMMLInternalException)1 HasClassLoaderMock (org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock)1