Search in sources :

Example 6 with Segmentation

use of org.dmg.pmml.mining.Segmentation 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)

Aggregations

MiningModel (org.dmg.pmml.mining.MiningModel)6 Segmentation (org.dmg.pmml.mining.Segmentation)6 Segment (org.dmg.pmml.mining.Segment)5 Model (org.dmg.pmml.Model)3 True (org.dmg.pmml.True)3 MiningSchema (org.dmg.pmml.MiningSchema)2 RegressionModel (org.dmg.pmml.regression.RegressionModel)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 JarFile (java.util.jar.JarFile)1 Manifest (java.util.jar.Manifest)1 TreeNode (ml.shifu.shifu.core.dtrain.dt.TreeNode)1 AbstractSpecifCreator (ml.shifu.shifu.core.pmml.builder.creator.AbstractSpecifCreator)1 MiningModelPmmlCreator (ml.shifu.shifu.core.pmml.builder.impl.MiningModelPmmlCreator)1 Application (org.dmg.pmml.Application)1 DataField (org.dmg.pmml.DataField)1 Header (org.dmg.pmml.Header)1 MiningField (org.dmg.pmml.MiningField)1 Output (org.dmg.pmml.Output)1 OutputField (org.dmg.pmml.OutputField)1