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


Java EvaluatorUtil.decode方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: evaluateSimple

import org.jpmml.evaluator.EvaluatorUtil; //导入方法依赖的package包/类
/**
 * @see #initializeArguments(Class, ObjectInspector[])
 * @see #initializeSimpleResult(Class)
 */
static
public Object evaluateSimple(Class<? extends GenericUDF> clazz, ObjectInspector[] inspectors, GenericUDF.DeferredObject[] objects) throws HiveException {
	Evaluator evaluator = getEvaluator(clazz);

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

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

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

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


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