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


Java EvaluatorUtil类代码示例

本文整理汇总了Java中org.jpmml.evaluator.EvaluatorUtil的典型用法代码示例。如果您正苦于以下问题:Java EvaluatorUtil类的具体用法?Java EvaluatorUtil怎么用?Java EvaluatorUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EvaluatorUtil类属于org.jpmml.evaluator包,在下文中一共展示了EvaluatorUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadPrimitiveList

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private Map<FieldName, FieldValue> loadPrimitiveList(Evaluator evaluator, Tuple tuple) throws ExecException {
	Map<FieldName, FieldValue> result = Maps.newLinkedHashMap();

	List<FieldName> activeFields = evaluator.getActiveFields();
	if(activeFields.size() != tuple.size()){
		throw new ExecException();
	}

	int i = 0;

	for(FieldName activeField : activeFields){
		Object object = tuple.get(i);

		FieldValue value = EvaluatorUtil.prepare(evaluator, activeField, object);

		result.put(activeField, value);

		i++;
	}

	return result;
}
 
开发者ID:jpmml,项目名称:jpmml-pig,代码行数:24,代码来源:PMMLUtil.java

示例2: storeResult

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private Tuple storeResult(Evaluator evaluator, Map<FieldName, ?> result){
	List<Object> values = Lists.newArrayList();

	List<FieldName> targetFields = evaluator.getTargetFields();
	for(FieldName targetField : targetFields){
		values.add(EvaluatorUtil.decode(result.get(targetField)));
	}

	List<FieldName> outputFields = evaluator.getOutputFields();
	for(FieldName outputField : outputFields){
		values.add(result.get(outputField));
	}

	TupleFactory tupleFactory = TupleFactory.getInstance();

	return tupleFactory.newTuple(values);
}
 
开发者ID:jpmml,项目名称:jpmml-pig,代码行数:19,代码来源:PMMLUtil.java

示例3: storeStruct

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private Object[] storeStruct(Evaluator evaluator, Map<FieldName, ?> result){
	List<Object> resultStruct = Lists.newArrayList();

	List<FieldName> targetFields = evaluator.getTargetFields();
	for(FieldName targetField : targetFields){
		resultStruct.add(EvaluatorUtil.decode(result.get(targetField)));
	}

	List<FieldName> outputFields = evaluator.getOutputFields();
	for(FieldName outputField : outputFields){
		resultStruct.add(result.get(outputField));
	}

	return resultStruct.toArray(new Object[resultStruct.size()]);
}
 
开发者ID:jpmml,项目名称:jpmml-hive,代码行数:17,代码来源:PMMLUtil.java

示例4: loadStruct

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private Map<FieldName, FieldValue> loadStruct(Evaluator evaluator, ResultSet request) throws SQLException {
	Map<FieldName, FieldValue> result = Maps.newLinkedHashMap();

	Map<String, Integer> columns = parseColumns(request);

	Iterable<FieldName> fields = evaluator.getActiveFields();
	for(FieldName field : fields){
		String label = normalize(field.getValue());

		Integer column = columns.get(label);
		if(column == null){
			continue;
		}

		FieldValue value = EvaluatorUtil.prepare(evaluator, field, request.getObject(column));

		result.put(field, value);
	}

	return result;
}
 
开发者ID:jpmml,项目名称:jpmml-postgresql,代码行数:23,代码来源:PMMLUtil.java

示例5: loadScalarList

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private Map<FieldName, FieldValue> loadScalarList(Evaluator evaluator, List<?> request){
	Map<FieldName, FieldValue> result = Maps.newLinkedHashMap();

	List<FieldName> fields = evaluator.getActiveFields();
	if(fields.size() != request.size()){
		throw new IllegalArgumentException("Invalid number of arguments");
	}

	int i = 0;

	for(FieldName field : fields){
		FieldValue value = EvaluatorUtil.prepare(evaluator, field, request.get(i));

		result.put(field, value);

		i++;
	}

	return result;
}
 
开发者ID:jpmml,项目名称:jpmml-postgresql,代码行数:22,代码来源:PMMLUtil.java

示例6: storeResult

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private void storeResult(Evaluator evaluator, Map<FieldName, ?> result, ResultSet response) throws SQLException {
	Map<String, Integer> columns = parseColumns(response);

	Iterable<FieldName> fields = Iterables.concat(evaluator.getTargetFields(), evaluator.getOutputFields());
	for(FieldName field : fields){
		String label = normalize(field.getValue());

		Integer column = columns.get(label);
		if(column == null){
			continue;
		}

		Object value = EvaluatorUtil.decode(result.get(field));
		if(value != null){
			response.updateObject(column, value);
		} else

		{
			response.updateNull(column);
		}
	}
}
 
开发者ID:jpmml,项目名称:jpmml-postgresql,代码行数:24,代码来源:PMMLUtil.java

示例7: doEquivalent

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
@Override
public boolean doEquivalent(Object expected, Object actual){

	if(actual instanceof Computable){
		actual = EvaluatorUtil.decode(actual);
	} // End if

	if(actual instanceof Number){
		actual = TypeUtil.parseOrCast(DataType.FLOAT, actual);
		expected = TypeUtil.parseOrCast(DataType.FLOAT, expected);
	}

	return super.doEquivalent(expected, actual);
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml-xgboost,代码行数:15,代码来源:XGBoostEquivalence.java

示例8: evaluateJPMMLModel

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
private boolean evaluateJPMMLModel(Evaluator evaluator, double[] inputValues) {
  boolean prediction = false;
  Map<FieldName, ?> arguments = prepareArguments(evaluator, inputValues);
  Map<FieldName, ?> result = evaluator.evaluate(arguments);
  ArrayList<FieldName> predictedFields = new ArrayList<FieldName>(evaluator.getPredictedFields());
  FieldName predictedField = predictedFields.get(0); // we are predicting only one field here
  //DataField dataField = evaluator.getDataField(predictedField); //only need for debug output
  Object predictedValue = result.get(predictedField);
  if (EvaluatorUtil.decode(predictedValue).equals("yes")) {
    prediction = true;
  }
  return prediction;
}
 
开发者ID:DhruvKumar,项目名称:iot-masterclass,代码行数:14,代码来源:SparkPredictionBolt.java

示例9: putPmmlScoresInEvent

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
private void putPmmlScoresInEvent(Map<FieldName, ?> predScores, Set<String> inserted,
        StreamlineEventImpl.Builder eventBuilder, List<FieldName> predOrOutFields, String msg) {

    for (FieldName predOrOutField : predOrOutFields) {
        final Object targetValue = predScores.get(predOrOutField);
        final String fieldName = predOrOutField.getValue();
        final Object predValue = EvaluatorUtil.decode(targetValue);
        eventBuilder.put(fieldName, predValue);
        LOG.debug(msg, fieldName, predValue);
        inserted.add(fieldName);
    }
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:13,代码来源:StreamlineJPMMLModelRunner.java

示例10: execute

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
@Override
public void execute(Tuple tuple){
	Evaluator evaluator = getEvaluator();

	Map<FieldName, FieldValue> arguments = new LinkedHashMap<>();

	List<FieldName> activeFields = evaluator.getActiveFields();
	for(FieldName activeField : activeFields){
		FieldValue value = EvaluatorUtil.prepare(evaluator, activeField, tuple.getValueByField(activeField.getValue()));

		arguments.put(activeField, value);
	}

	Map<FieldName, ?> result = evaluator.evaluate(arguments);

	Values values = new Values();

	List<FieldName> targetFields = evaluator.getTargetFields();
	for(FieldName targetField : targetFields){
		Object targetValue = result.get(targetField);

		values.add(EvaluatorUtil.decode(targetValue));
	}

	List<FieldName> outputFields = evaluator.getOutputFields();
	for(FieldName outputField : outputFields){
		Object outputValue = result.get(outputField);

		values.add(outputValue);
	}

	OutputCollector collector = getCollector();

	collector.emit(tuple, values);
	collector.ack(tuple);
}
 
开发者ID:jpmml,项目名称:jpmml-storm,代码行数:37,代码来源:PMMLBolt.java

示例11: aggregateVotes

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
public <V extends Number> ValueMap<String, V> aggregateVotes(final ValueFactory<V> valueFactory, List<SegmentResult> segmentResults, Segmentation.MultipleModelMethod multipleModelMethod){
	VoteAggregator<String, V> aggregator = new VoteAggregator<String, V>(){

		@Override
		public ValueFactory<V> getValueFactory(){
			return valueFactory;
		}
	};

	for(SegmentResult segmentResult : segmentResults){
		String key;

		try {
			Object targetValue = EvaluatorUtil.decode(segmentResult.getTargetValue());

			key = (String)TypeUtil.cast(DataType.STRING, targetValue);
		} catch(TypeCheckException tce){
			throw tce.ensureContext(segmentResult.getSegment());
		}

		switch(multipleModelMethod){
			case MAJORITY_VOTE:
				aggregator.add(key);
				break;
			case WEIGHTED_MAJORITY_VOTE:
				double weight = segmentResult.getWeight();

				aggregator.add(key, weight);
				break;
			default:
				throw new IllegalArgumentException();
		}
	}

	return aggregator.sumMap();
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:38,代码来源:MiningModelUtil.java

示例12: decodeArguments

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private Map<FieldName, FieldValue> decodeArguments(Evaluator evaluator, TupleEntry tuple){
	Map<FieldName, FieldValue> result = new LinkedHashMap<>();

	Fields fields = tuple.getFields();

	for(int i = 0; i < fields.size(); i++){
		FieldName key = FieldName.create((String)fields.get(i));
		Object value = tuple.getObject(key.getValue());

		result.put(key, EvaluatorUtil.prepare(evaluator, key, value));
	}

	return result;
}
 
开发者ID:jpmml,项目名称:jpmml-cascading,代码行数:16,代码来源:PMMLFunction.java

示例13: encodeResult

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private TupleEntry encodeResult(Evaluator evaluator, Fields fields, Map<FieldName, ?> map){
	TupleEntry result = new TupleEntry(fields, Tuple.size(fields.size()));

	for(int i = 0; i < fields.size(); i++){
		FieldName key = FieldName.create((String)fields.get(i));
		Object value = map.get(key);

		result.setRaw(key.getValue(), EvaluatorUtil.decode(value));
	}

	return result;
}
 
开发者ID:jpmml,项目名称:jpmml-cascading,代码行数:14,代码来源:PMMLFunction.java

示例14: exec

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
@Override
public Tuple exec(Tuple input) throws IOException {

	// check
	int dummy = 0;
	
	// Initialize Evaluator if null:
	if (this.evaluator == null) {
		try {
			System.out.println("Initializing: "+(dummy++)+" time");
			Schema inputSchema = getInputSchema();
			this.initialize(inputSchema);			// something to check
		} catch (Throwable t) {
			throw new RuntimeException("Backend: Unable to initialize PMML file: ",t);
		}
	}

	// Initialize Output as Input
	Tuple outputTuple = tf.newTuple(this.predictedFields.size() + this.outputFields.size());

	/* ************************
	// BLOCK: Prepare Data
	************************* */
	
	for(FieldName inputField : this.activeFields){

		// Get Object
		Object origBodyCell = (Object) input.get(aliasMap.get(inputField.getValue().toLowerCase()));
		
		Object bodyCell;
		if (origBodyCell instanceof Long) {
			bodyCell = ((Long) origBodyCell).doubleValue();
		} else {
			bodyCell = origBodyCell;
		}

		// Prepare Object for Scoring
		this.preparedRow.put(inputField, EvaluatorUtil.prepare(this.evaluator, inputField, bodyCell));

		// Prepare Object for Scoring
		// CC: Removed this b/c I think the "Long" check above resolves any issues.
		/*
		try {
			this.preparedRow.put(inputField, EvaluatorUtil.prepare(this.evaluator, inputField, bodyCell));
		} catch (Throwable t) {
        	System.err.println("Unable to prepare record, Trouble Parsing: " + inputField.toString() + " (value="+ bodyCell+")");
        	System.err.println(t);
            throw new RuntimeException(t);
		}
		*/

	}

	// Score Data
	Map<FieldName, ?> result = evaluator.evaluate(this.preparedRow);

	// Append Predicted Fields
	int i = 0;
	for(FieldName predictedField : this.predictedFields){
		outputTuple.set(i++,EvaluatorUtil.decode(result.get(predictedField)));
	}

	for(FieldName outputField : this.outputFields){
		outputTuple.set(i++,EvaluatorUtil.decode(result.get(outputField)));
	}

	// Return Tuple:
	return outputTuple;

}
 
开发者ID:Netflix,项目名称:Surus,代码行数:71,代码来源:ScorePMML.java

示例15: evaluateSimple

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
public Object evaluateSimple(Class<?> clazz, Tuple tuple) throws IOException {

	if(tuple == null){
		return null;
	}

	Evaluator evaluator = getEvaluator(clazz);

	Map<FieldName, FieldValue> arguments = loadArguments(evaluator, tuple);

	Map<FieldName, ?> result = evaluator.evaluate(arguments);

	Object targetValue = result.get(evaluator.getTargetField());

	return EvaluatorUtil.decode(targetValue);
}
 
开发者ID:jpmml,项目名称:jpmml-pig,代码行数:18,代码来源:PMMLUtil.java


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