Search in sources :

Example 11 with PMML4Model

use of org.kie.pmml.pmml_4_2.PMML4Model in project drools by kiegroup.

the class PMML4UnitImpl method initModelsMap.

/**
 * Initializes the internal map of models. This map includes all models that are
 * defined within the PMML, including child models (i.e. models contained within models)
 */
private void initModelsMap() {
    modelsMap = new HashMap<>();
    List<PMML4Model> rootModels = modelFactory.getModels(this);
    if (rootModels != null && !rootModels.isEmpty()) {
        for (PMML4Model model : rootModels) {
            modelsMap.put(model.getModelId(), model);
            addChildModelsToMap(model);
        }
    } else {
        throw new IllegalStateException("BRMS-PMML requires at least one model of the model types that are recognized");
    }
}
Also used : PMML4Model(org.kie.pmml.pmml_4_2.PMML4Model)

Example 12 with PMML4Model

use of org.kie.pmml.pmml_4_2.PMML4Model in project drools by kiegroup.

the class PMML4UnitImpl method getChildModels.

/**
 * Retrieves a Map whose entries consist of
 *    key -> a model identifier
 *    value -> the PMML4Model object that the key refers to
 * where the PMML4Model indicates that it
 * @param parentModelId
 * @return
 */
public Map<String, PMML4Model> getChildModels(String parentModelId) {
    PMML4Model parent = modelsMap.get(parentModelId);
    Map<String, PMML4Model> childMap = parent.getChildModels();
    return (childMap != null && !childMap.isEmpty()) ? new HashMap<>(childMap) : new HashMap<>();
}
Also used : PMML4Model(org.kie.pmml.pmml_4_2.PMML4Model)

Example 13 with PMML4Model

use of org.kie.pmml.pmml_4_2.PMML4Model in project drools by kiegroup.

the class PMML4UnitImpl method getMiningFields.

/**
 * Retrieves a Map with entries that consist of
 * key -> a model identifier
 * value -> the List of raw MiningField objects belonging to the model referenced by the key
 * @return The Map of model identifiers and their corresponding list of raw MiningField objects
 */
public Map<String, List<MiningField>> getMiningFields() {
    Map<String, List<MiningField>> miningFieldsMap = new HashMap<>();
    for (PMML4Model model : getModels()) {
        List<MiningField> miningFields = model.getRawMiningFields();
        miningFieldsMap.put(model.getModelId(), miningFields);
        model.getChildModels();
    }
    return miningFieldsMap;
}
Also used : MiningField(org.kie.dmg.pmml.pmml_4_2.descr.MiningField) HashMap(java.util.HashMap) PMML4Model(org.kie.pmml.pmml_4_2.PMML4Model) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

PMML4Model (org.kie.pmml.pmml_4_2.PMML4Model)10 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 PMML (org.kie.dmg.pmml.pmml_4_2.descr.PMML)3 RegressionModel (org.kie.dmg.pmml.pmml_4_2.descr.RegressionModel)3 Scorecard (org.kie.dmg.pmml.pmml_4_2.descr.Scorecard)3 TreeModel (org.kie.dmg.pmml.pmml_4_2.descr.TreeModel)3 PMML4UnitImpl (org.kie.pmml.pmml_4_2.model.PMML4UnitImpl)3 List (java.util.List)2 Map (java.util.Map)2 PMMLResource (org.drools.compiler.compiler.PMMLResource)2 KieServices (org.kie.api.KieServices)2 KieBaseModel (org.kie.api.builder.model.KieBaseModel)2 KieModuleModel (org.kie.api.builder.model.KieModuleModel)2 MiningField (org.kie.dmg.pmml.pmml_4_2.descr.MiningField)2 KnowledgeBuilderResult (org.kie.internal.builder.KnowledgeBuilderResult)2 Miningmodel (org.kie.pmml.pmml_4_2.model.Miningmodel)2 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1