All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mml-models-tree-model.10.0.0.source-code.KiePMMLNodeTemplate.tmpl Maven / Gradle / Ivy

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.kie.pmml.models.tree.model;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;

import org.kie.pmml.commons.model.KiePMMLOutputField;
import org.kie.pmml.commons.model.predicates.KiePMMLCompoundPredicate;
import org.kie.pmml.commons.model.predicates.KiePMMLFalsePredicate;
import org.kie.pmml.commons.model.predicates.KiePMMLPredicate;
import org.kie.pmml.commons.model.predicates.KiePMMLSimplePredicate;
import org.kie.pmml.commons.model.predicates.KiePMMLSimpleSetPredicate;
import org.kie.pmml.commons.model.predicates.KiePMMLTruePredicate;
import org.kie.pmml.api.enums.PMML_MODEL;
import org.kie.pmml.models.tree.model.KiePMMLNode;
import org.kie.pmml.models.tree.model.KiePMMLNodeResult;
import org.kie.pmml.models.tree.model.KiePMMLScoreDistribution;



public class KiePMMLNodeTemplate extends KiePMMLNode {

    public KiePMMLNodeTemplate() {
        super(name, Collections.emptyList());
    }

    public static KiePMMLNodeResult evaluateNode(final Map requestData) {
            if (!predicate.evaluate(requestData)) {
                return null;
            }
            final List, KiePMMLNodeResult>> nodeFunctions = null;
            final Object score = null;
            final List scoreDistributions = null;
            final double missingValuePenalty = 1.0;
            KiePMMLNodeResult kiePMMLNodeResult = new KiePMMLNodeResult(score, KiePMMLNode.getProbabilityConfidenceMap(scoreDistributions, missingValuePenalty));
            if (nodeFunctions.isEmpty()) {
                return kiePMMLNodeResult;
            }
            Optional nestedKiePMMLNodeResult = KiePMMLNode.getNestedKiePMMLNodeResult(nodeFunctions, requestData);
            return nestedKiePMMLNodeResult.orElse(kiePMMLNodeResult);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy