• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EvaluatorUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: loadStruct

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private Map<FieldName, FieldValue> loadStruct(Evaluator evaluator, ObjectInspector inspector, GenericUDF.DeferredObject object) throws HiveException {
	Map<FieldName, FieldValue> result = Maps.newLinkedHashMap();

	StructObjectInspector structInspector = (StructObjectInspector)inspector;

	Object structObject = object.get();

	List<FieldName> activeFields = evaluator.getActiveFields();
	for(FieldName activeField : activeFields){
		StructField structField = structInspector.getStructFieldRef(activeField.getValue());

		PrimitiveObjectInspector primitiveObjectInspector = (PrimitiveObjectInspector)structField.getFieldObjectInspector();

		Object primitiveObject = structInspector.getStructFieldData(structObject, structField);

		FieldValue value = EvaluatorUtil.prepare(evaluator, activeField, primitiveObjectInspector.getPrimitiveJavaObject(primitiveObject));

		result.put(activeField, value);
	}

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


示例17: loadPrimitiveList

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
static
private Map<FieldName, FieldValue> loadPrimitiveList(Evaluator evaluator, ObjectInspector[] inspectors, GenericUDF.DeferredObject[] objects) throws HiveException {
	Map<FieldName, FieldValue> result = Maps.newLinkedHashMap();

	int i = 0;

	List<FieldName> activeFields = evaluator.getActiveFields();
	for(FieldName activeField : activeFields){
		PrimitiveObjectInspector primitiveInspector = (PrimitiveObjectInspector)inspectors[i];

		Object primitiveObject = objects[i].get();

		FieldValue value = EvaluatorUtil.prepare(evaluator, activeField, primitiveInspector.getPrimitiveJavaObject(primitiveObject));

		result.put(activeField, value);

		i++;
	}

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


示例18: evaluateSimple

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

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

	Evaluator evaluator = getEvaluator(clazz);

	Map<FieldName, ?> arguments = loadArguments(evaluator, request);

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

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

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


示例19: aggregateValues

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

	switch(multipleModelMethod){
		case AVERAGE:
		case SUM:
			aggregator = new ValueAggregator<>(valueFactory.newVector(0));
			break;
		case MEDIAN:
			aggregator = new ValueAggregator<>(valueFactory.newVector(segmentResults.size()));
			break;
		case WEIGHTED_AVERAGE:
		case WEIGHTED_SUM:
			aggregator = new ValueAggregator<>(valueFactory.newVector(0), valueFactory.newVector(0), valueFactory.newVector(0));
			break;
		case WEIGHTED_MEDIAN:
			aggregator = new ValueAggregator<>(valueFactory.newVector(segmentResults.size()), valueFactory.newVector(segmentResults.size()));
			break;
		default:
			throw new IllegalArgumentException();
	}

	for(SegmentResult segmentResult : segmentResults){
		Number value;

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

			if(targetValue instanceof Number){
				value = (Number)targetValue;
			} else

			{
				value = (Double)TypeUtil.cast(DataType.DOUBLE, targetValue);
			}
		} catch(TypeCheckException tce){
			throw tce.ensureContext(segmentResult.getSegment());
		}

		switch(multipleModelMethod){
			case AVERAGE:
			case SUM:
			case MEDIAN:
				aggregator.add(value);
				break;
			case WEIGHTED_AVERAGE:
			case WEIGHTED_SUM:
			case WEIGHTED_MEDIAN:
				double weight = segmentResult.getWeight();

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

	switch(multipleModelMethod){
		case AVERAGE:
			return aggregator.average();
		case WEIGHTED_AVERAGE:
			return aggregator.weightedAverage();
		case SUM:
			return aggregator.sum();
		case WEIGHTED_SUM:
			return aggregator.weightedSum();
		case MEDIAN:
			return aggregator.median();
		case WEIGHTED_MEDIAN:
			return aggregator.weightedMedian();
		default:
			throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:76,代码来源:MiningModelUtil.java


示例20: evaluate

import org.jpmml.evaluator.EvaluatorUtil; //导入依赖的package包/类
@Test
public void evaluate() throws Exception {
	CountingModelEvaluatorFactory evaluatorFactory = new CountingModelEvaluatorFactory();

	Evaluator evaluator = createModelEvaluator(evaluatorFactory);

	Map<FieldName, ?> arguments = createArguments("sepal_length", 5.1d, "sepal_width", 3.5d, "petal_length", 1.4d, "petal_width", 0.2d);

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

	assertEquals(1, evaluatorFactory.getMiningModelCount());
	assertEquals(5, evaluatorFactory.getTreeModelCount());

	assertEquals(1, result.size());

	Collection<?> species = (Collection<?>)result.get(FieldName.create("species"));

	assertEquals(5, species.size());

	for(Object value : species){
		assertTrue((value instanceof Computable) & (value instanceof HasEntityId));
	}

	assertEquals(Arrays.asList("setosa", "setosa", "setosa", "setosa", "versicolor"), EvaluatorUtil.decode(species));
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:26,代码来源:SelectAllTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MouseDragEvent类代码示例发布时间:2022-05-21
下一篇:
Java ChangeLogSet类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap