Search in sources :

Example 6 with KiePMMLNameOpType

use of org.kie.pmml.commons.model.tuples.KiePMMLNameOpType in project drools by kiegroup.

the class ModelUtils method getTargetFields.

/**
 * Return a <code>List&lt;KiePMMLNameOpType&gt;</code> of target fields
 * Please note that only <b>predicted/target</b>
 * <code>MiningField</code> are considered.
 * @param fields
 * @param model
 * @return
 */
public static List<KiePMMLNameOpType> getTargetFields(final List<Field<?>> fields, final Model model) {
    List<KiePMMLNameOpType> toReturn = new ArrayList<>();
    if (model.getMiningSchema() != null && model.getMiningSchema().getMiningFields() != null) {
        for (MiningField miningField : model.getMiningSchema().getMiningFields()) {
            if (MiningField.UsageType.TARGET.equals(miningField.getUsageType()) || MiningField.UsageType.PREDICTED.equals(miningField.getUsageType())) {
                OP_TYPE opType = getOpType(fields, model, miningField.getName().getValue());
                toReturn.add(new KiePMMLNameOpType(miningField.getName().getValue(), opType));
            }
        }
    }
    return toReturn;
}
Also used : KiePMMLNameOpType(org.kie.pmml.commons.model.tuples.KiePMMLNameOpType) MiningField(org.dmg.pmml.MiningField) ArrayList(java.util.ArrayList) OP_TYPE(org.kie.pmml.api.enums.OP_TYPE)

Aggregations

MiningField (org.dmg.pmml.MiningField)6 KiePMMLNameOpType (org.kie.pmml.commons.model.tuples.KiePMMLNameOpType)6 ArrayList (java.util.ArrayList)5 DataDictionary (org.dmg.pmml.DataDictionary)5 DataField (org.dmg.pmml.DataField)5 MiningSchema (org.dmg.pmml.MiningSchema)5 Model (org.dmg.pmml.Model)5 RegressionModel (org.dmg.pmml.regression.RegressionModel)5 Test (org.junit.Test)5 Arrays (java.util.Arrays)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 LinkedHashMap (java.util.LinkedHashMap)4 List (java.util.List)4 Map (java.util.Map)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 IntStream (java.util.stream.IntStream)4 Array (org.dmg.pmml.Array)4