本文整理汇总了Java中org.jpmml.evaluator.Evaluator.prepare方法的典型用法代码示例。如果您正苦于以下问题:Java Evaluator.prepare方法的具体用法?Java Evaluator.prepare怎么用?Java Evaluator.prepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jpmml.evaluator.Evaluator
的用法示例。
在下文中一共展示了Evaluator.prepare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object evaluate(Message<?> input) {
Model model = selectModel(input);
Evaluator evaluator = modelEvaluatorFactory.newModelManager(pmml, model);
Map<FieldName, FieldValue> arguments = new LinkedHashMap<>();
List<FieldName> activeFields = evaluator.getActiveFields();
for (FieldName activeField : activeFields) {
// The raw (ie. user-supplied) value could be any Java primitive value
Object rawValue = resolveActiveValue(input, activeField.getValue());
// The raw value is passed through:
// 1) outlier treatment,
// 2) missing value treatment,
// 3) invalid value treatment
// and 4) type conversion
FieldValue activeValue = evaluator.prepare(activeField, rawValue);
arguments.put(activeField, activeValue);
}
Map<FieldName, ?> results = evaluator.evaluate(arguments);
MutableMessage<?> result = convertToMutable(input);
for (Map.Entry<FieldName, ?> entry : results.entrySet()) {
String fieldName = null;
if (entry.getKey()==null)
fieldName = DEFAULT_OUTPUT_FIELD;
else
fieldName = entry.getKey().getValue();
Expression expression = properties.getOutputs().get(fieldName);
if (expression == null) {
expression = spelExpressionParser.parseExpression("payload." + fieldName);
}
if (logger.isDebugEnabled()) {
logger.debug("Setting result field named " + fieldName + " using SpEL[" + expression + " = "
+ entry.getValue() + "]");
}
expression.setValue(evaluationContext, result, entry.getValue());
}
return result;
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:49,代码来源:PmmlProcessorConfiguration.java
示例2: evaluate
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> T evaluate(Double[] values, Evaluator evaluator){
List<FieldName> activeFields = evaluator.getActiveFields();
Map<FieldName, FieldValue> arguments = new LinkedHashMap<FieldName, FieldValue>();
int i = 0;
for(FieldName activeField : activeFields){
// The raw (ie. user-supplied) value could be any Java primitive value
Object rawValue = values[i];
// The raw value is passed through: 1) outlier treatment, 2) missing value treatment, 3) invalid value treatment and 4) type conversion
FieldValue activeValue = evaluator.prepare(activeField, rawValue);
arguments.put(activeField, activeValue);
i++;
}
Map<FieldName, ?> results = evaluator.evaluate(arguments);
FieldName targetName = evaluator.getTargetField();
return (T)results.get(targetName);
}