当前位置: 首页>>代码示例>>Java>>正文


Java Evaluator.prepare方法代码示例

本文整理汇总了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);	
	
}
 
开发者ID:selvinsource,项目名称:spark-pmml-exporter-validator,代码行数:27,代码来源:SparkPMMLExporterValidator.java


注:本文中的org.jpmml.evaluator.Evaluator.prepare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。