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;
}
Aggregations