Search in sources :

Example 1 with TestModel

use of org.kie.pmml.compiler.api.mocks.TestModel 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 2 with TestModel

use of org.kie.pmml.compiler.api.mocks.TestModel in project drools by kiegroup.

the class PMMLModelTestUtils method getRandomMiningModel.

public static MiningModel getRandomMiningModel(DataDictionary dataDictionary) {
    MiningModel toReturn = new MiningModel();
    List<DataField> dataFields = dataDictionary.getDataFields();
    MiningSchema miningSchema = new MiningSchema();
    IntStream.range(0, dataFields.size() - 1).forEach(i -> {
        DataField dataField = dataFields.get(i);
        MiningField miningField = new MiningField();
        miningField.setName(dataField.getName());
        miningField.setUsageType(MiningField.UsageType.ACTIVE);
        miningSchema.addMiningFields(miningField);
    });
    DataField lastDataField = dataFields.get(dataFields.size() - 1);
    MiningField predictedMiningField = new MiningField();
    predictedMiningField.setName(lastDataField.getName());
    predictedMiningField.setUsageType(MiningField.UsageType.PREDICTED);
    miningSchema.addMiningFields(predictedMiningField);
    Output output = new Output();
    OutputField outputField = new OutputField();
    outputField.setName(FieldName.create("OUTPUT_" + lastDataField.getName().getValue()));
    outputField.setDataType(lastDataField.getDataType());
    outputField.setOpType(getRandomOpType());
    toReturn.setModelName(RandomStringUtils.random(6, true, false));
    toReturn.setMiningSchema(miningSchema);
    toReturn.setOutput(output);
    TestModel testModel = getRandomTestModel(dataDictionary);
    Segment segment = new Segment();
    segment.setModel(testModel);
    Segmentation segmentation = new Segmentation();
    segmentation.addSegments(segment);
    toReturn.setSegmentation(segmentation);
    return toReturn;
}
Also used : MiningField(org.dmg.pmml.MiningField) MiningModel(org.dmg.pmml.mining.MiningModel) DataField(org.dmg.pmml.DataField) MiningSchema(org.dmg.pmml.MiningSchema) Segmentation(org.dmg.pmml.mining.Segmentation) Output(org.dmg.pmml.Output) OutputField(org.dmg.pmml.OutputField) TestModel(org.kie.pmml.compiler.api.mocks.TestModel) Segment(org.dmg.pmml.mining.Segment)

Example 3 with TestModel

use of org.kie.pmml.compiler.api.mocks.TestModel in project drools by kiegroup.

the class PMMLModelTestUtils method getRandomTestModel.

public static TestModel getRandomTestModel(DataDictionary dataDictionary) {
    TestModel toReturn = new TestModel();
    List<DataField> dataFields = dataDictionary.getDataFields();
    MiningSchema miningSchema = new MiningSchema();
    IntStream.range(0, dataFields.size() - 1).forEach(i -> {
        DataField dataField = dataFields.get(i);
        MiningField miningField = new MiningField();
        miningField.setName(dataField.getName());
        miningField.setUsageType(MiningField.UsageType.ACTIVE);
        miningSchema.addMiningFields(miningField);
    });
    DataField lastDataField = dataFields.get(dataFields.size() - 1);
    MiningField predictedMiningField = new MiningField();
    predictedMiningField.setName(lastDataField.getName());
    predictedMiningField.setUsageType(MiningField.UsageType.PREDICTED);
    miningSchema.addMiningFields(predictedMiningField);
    Output output = new Output();
    OutputField outputField = new OutputField();
    outputField.setName(FieldName.create("OUTPUT_" + lastDataField.getName().getValue()));
    outputField.setDataType(lastDataField.getDataType());
    outputField.setOpType(getRandomOpType());
    toReturn.setModelName(RandomStringUtils.random(6, true, false));
    toReturn.setMiningSchema(miningSchema);
    toReturn.setOutput(output);
    return toReturn;
}
Also used : MiningField(org.dmg.pmml.MiningField) DataField(org.dmg.pmml.DataField) MiningSchema(org.dmg.pmml.MiningSchema) Output(org.dmg.pmml.Output) OutputField(org.dmg.pmml.OutputField) TestModel(org.kie.pmml.compiler.api.mocks.TestModel)

Aggregations

TestModel (org.kie.pmml.compiler.api.mocks.TestModel)3 DataField (org.dmg.pmml.DataField)2 MiningField (org.dmg.pmml.MiningField)2 MiningSchema (org.dmg.pmml.MiningSchema)2 Output (org.dmg.pmml.Output)2 OutputField (org.dmg.pmml.OutputField)2 MiningModel (org.dmg.pmml.mining.MiningModel)1 Segment (org.dmg.pmml.mining.Segment)1 Segmentation (org.dmg.pmml.mining.Segmentation)1 Test (org.junit.Test)1 KiePMMLModel (org.kie.pmml.commons.model.KiePMMLModel)1 KiePMMLTestingModel (org.kie.pmml.commons.testingutility.KiePMMLTestingModel)1 PMMLModelTestUtils.getPMMLWithMiningRandomTestModel (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithMiningRandomTestModel)1 PMMLModelTestUtils.getPMMLWithRandomTestModel (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getPMMLWithRandomTestModel)1 HasClassLoaderMock (org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock)1