Search in sources :

Example 1 with TargetValue

use of org.dmg.pmml.TargetValue in project shifu by ShifuML.

the class NNPmmlModelCreator method createTargets.

public Targets createTargets() {
    Targets targets = new Targets();
    if (modelConfig.isClassification() && ModelTrainConf.MultipleClassification.NATIVE.equals(modelConfig.getTrain().getMultiClassifyMethod())) {
        List<Target> targetList = createMultiClassTargets();
        targets.addTargets(targetList.toArray(new Target[targetList.size()]));
    } else {
        Target target = new Target();
        target.setOpType(OpType.CONTINUOUS);
        target.setField(new FieldName(modelConfig.getTargetColumnName()));
        List<TargetValue> targetValueList = new ArrayList<TargetValue>();
        if (CollectionUtils.isNotEmpty(modelConfig.getPosTags())) {
            for (String posTagValue : modelConfig.getPosTags()) {
                TargetValue pos = new TargetValue();
                pos.setValue(posTagValue);
                pos.setDisplayValue("Positive");
                targetValueList.add(pos);
            }
        }
        if (CollectionUtils.isNotEmpty(modelConfig.getNegTags())) {
            for (String negTagValue : modelConfig.getNegTags()) {
                TargetValue neg = new TargetValue();
                neg.setValue(negTagValue);
                neg.setDisplayValue("Negative");
                targetValueList.add(neg);
            }
        }
        target.addTargetValues(targetValueList.toArray(new TargetValue[targetValueList.size()]));
        targets.addTargets(target);
    }
    return targets;
}
Also used : Target(org.dmg.pmml.Target) TargetValue(org.dmg.pmml.TargetValue) ArrayList(java.util.ArrayList) Targets(org.dmg.pmml.Targets) FieldName(org.dmg.pmml.FieldName)

Example 2 with TargetValue

use of org.dmg.pmml.TargetValue in project shifu by ShifuML.

the class TreeEnsemblePmmlCreator method createTargets.

protected Targets createTargets(ModelConfig modelConfig) {
    Targets targets = new Targets();
    Target target = new Target();
    target.setOpType(OpType.CATEGORICAL);
    target.setField(new FieldName(modelConfig.getTargetColumnName()));
    List<TargetValue> targetValueList = new ArrayList<TargetValue>();
    for (String posTagValue : modelConfig.getPosTags()) {
        TargetValue pos = new TargetValue();
        pos.setValue(posTagValue);
        pos.setDisplayValue("Positive");
        targetValueList.add(pos);
    }
    for (String negTagValue : modelConfig.getNegTags()) {
        TargetValue neg = new TargetValue();
        neg.setValue(negTagValue);
        neg.setDisplayValue("Negative");
        targetValueList.add(neg);
    }
    target.addTargetValues(targetValueList.toArray(new TargetValue[targetValueList.size()]));
    targets.addTargets(target);
    return targets;
}
Also used : Target(org.dmg.pmml.Target) TargetValue(org.dmg.pmml.TargetValue) ArrayList(java.util.ArrayList) Targets(org.dmg.pmml.Targets) FieldName(org.dmg.pmml.FieldName)

Example 3 with TargetValue

use of org.dmg.pmml.TargetValue in project drools by kiegroup.

the class KiePMMLTargetValueInstanceFactoryTest method getKiePMMLTargetValue.

@Test
public void getKiePMMLTargetValue() {
    final TargetValue toConvert = getRandomTargetValue();
    KiePMMLTargetValue retrieved = KiePMMLTargetValueInstanceFactory.getKiePMMLTargetValue(toConvert);
    commonVerifyKiePMMLTargetValue(retrieved, toConvert);
}
Also used : TargetValue(org.dmg.pmml.TargetValue) KiePMMLTargetValue(org.kie.pmml.commons.model.KiePMMLTargetValue) InstanceFactoriesTestCommon.commonVerifyKiePMMLTargetValue(org.kie.pmml.compiler.commons.factories.InstanceFactoriesTestCommon.commonVerifyKiePMMLTargetValue) PMMLModelTestUtils.getRandomTargetValue(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRandomTargetValue) KiePMMLTargetValue(org.kie.pmml.commons.model.KiePMMLTargetValue) InstanceFactoriesTestCommon.commonVerifyKiePMMLTargetValue(org.kie.pmml.compiler.commons.factories.InstanceFactoriesTestCommon.commonVerifyKiePMMLTargetValue) Test(org.junit.Test)

Example 4 with TargetValue

use of org.dmg.pmml.TargetValue in project drools by kiegroup.

the class PMMLModelTestUtils method getRandomTargetValue.

public static TargetValue getRandomTargetValue() {
    Random random = new Random();
    TargetValue toReturn = new TargetValue();
    toReturn.setValue(random.nextDouble());
    toReturn.setDisplayValue(RandomStringUtils.random(6, true, false));
    toReturn.setDefaultValue(random.nextFloat());
    toReturn.setPriorProbability((double) random.nextInt(100) / 13);
    return toReturn;
}
Also used : TargetValue(org.dmg.pmml.TargetValue) Random(java.util.Random)

Example 5 with TargetValue

use of org.dmg.pmml.TargetValue in project shifu by ShifuML.

the class TreeModelPmmlElementCreator method createTargets.

protected Targets createTargets(ModelConfig modelConfig) {
    Targets targets = new Targets();
    Target target = new Target();
    target.setOpType(OpType.CATEGORICAL);
    target.setField(new FieldName(modelConfig.getTargetColumnName()));
    List<TargetValue> targetValueList = new ArrayList<TargetValue>();
    for (String posTagValue : modelConfig.getPosTags()) {
        TargetValue pos = new TargetValue();
        pos.setValue(posTagValue);
        pos.setDisplayValue("Positive");
        targetValueList.add(pos);
    }
    for (String negTagValue : modelConfig.getNegTags()) {
        TargetValue neg = new TargetValue();
        neg.setValue(negTagValue);
        neg.setDisplayValue("Negative");
        targetValueList.add(neg);
    }
    target.addTargetValues(targetValueList.toArray(new TargetValue[targetValueList.size()]));
    targets.addTargets(target);
    return targets;
}
Also used : Target(org.dmg.pmml.Target) TargetValue(org.dmg.pmml.TargetValue) ArrayList(java.util.ArrayList) Targets(org.dmg.pmml.Targets) FieldName(org.dmg.pmml.FieldName)

Aggregations

TargetValue (org.dmg.pmml.TargetValue)6 ArrayList (java.util.ArrayList)4 FieldName (org.dmg.pmml.FieldName)4 Target (org.dmg.pmml.Target)4 Targets (org.dmg.pmml.Targets)3 Random (java.util.Random)1 Test (org.junit.Test)1 KiePMMLTargetValue (org.kie.pmml.commons.model.KiePMMLTargetValue)1 PMMLModelTestUtils.getRandomTargetValue (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRandomTargetValue)1 InstanceFactoriesTestCommon.commonVerifyKiePMMLTargetValue (org.kie.pmml.compiler.commons.factories.InstanceFactoriesTestCommon.commonVerifyKiePMMLTargetValue)1