本文整理汇总了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);
}
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}