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

mml-models-regression-model.8.34.0.Final.source-code.KiePMMLEvaluateMethodTemplate.tmpl Maven / Gradle / Ivy

There is a newer version: 10.0.0
Show newest version
package org.kie.pmml.models.regression.model;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;


public class KiePMMLEvaluateMethodTemplate {

    private double evaluateNumericWithExponent(double input) {
        // Considering exponent because it is != 1
        return evaluateNumericWithExponent(input, coefficient, exponent);
    }

    private double evaluateNumericWithoutExponent(double input) {
        // Ignoring exponent because it is 1
        return evaluateNumericWithoutExponent(input, coefficient);
    }

    private double evaluateCategorical(Object input) {
//        if (Objects.equals("x", input)) {
//            return -3;
//        } else if (Objects.equals("y", input)) {
//            return 3;
//        } else {
//            return 0.0;
//        }
    }

    private double evaluatePredictor(Map resultMap) {
        final AtomicReference result = new AtomicReference<>(1.0);
        List fieldRefs = Arrays.asList("fld1", "fld2");
        for (String key : resultMap.keySet()) {
            if (fieldRefs.contains(key)) {
                result.set(result.get() * (Double)resultMap.get(key));
            }
        }
        double coefficient = 0.4;
        return result.get() * coefficient;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy