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


Java FieldValue类代码示例

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


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

示例1: loadArguments

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

	if(tuple.size() == 1){
		byte type = tuple.getType(0);

		switch(type){
			case DataType.TUPLE:
				return loadPrimitiveList(evaluator, (Tuple)tuple.get(0));
			default:
				break;
		}
	}

	return loadPrimitiveList(evaluator, tuple);
}
 
开发者ID:jpmml,项目名称:jpmml-pig,代码行数:17,代码来源:PMMLUtil.java

示例2: loadPrimitiveList

import org.jpmml.evaluator.FieldValue; //导入依赖的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

示例3: loadArguments

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

	if(inspectors.length == 1){
		ObjectInspector inspector = inspectors[0];

		ObjectInspector.Category category = inspector.getCategory();
		switch(category){
			case STRUCT:
				return loadStruct(evaluator, inspectors[0], objects[0]);
			default:
				return loadPrimitiveList(evaluator, inspectors, objects);
		}
	}

	return loadPrimitiveList(evaluator, inspectors, objects);
}
 
开发者ID:jpmml,项目名称:jpmml-hive,代码行数:18,代码来源:PMMLUtil.java

示例4: loadStruct

import org.jpmml.evaluator.FieldValue; //导入依赖的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.FieldValue; //导入依赖的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: getBaselineStratum

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
static
private BaselineStratum getBaselineStratum(BaseCumHazardTables baseCumHazardTables, FieldValue value){

	if(baseCumHazardTables instanceof HasParsedValueMapping){
		HasParsedValueMapping<?> hasParsedValueMapping = (HasParsedValueMapping<?>)baseCumHazardTables;

		return (BaselineStratum)value.getMapping(hasParsedValueMapping);
	}

	List<BaselineStratum> baselineStrata = baseCumHazardTables.getBaselineStrata();
	for(BaselineStratum baselineStratum : baselineStrata){
		String category = baselineStratum.getValue();
		if(category == null){
			throw new MissingAttributeException(baselineStratum, PMMLAttributes.BASELINESTRATUM_VALUE);
		} // End if

		if(value.equalsString(category)){
			return baselineStratum;
		}
	}

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

示例7: updateProduct

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
@Override
public <V extends Number> Value<V> updateProduct(Value<V> product, FieldValue value){
	Matrix matrix = getMatrix();

	int row = getIndex(value);
	int column = getIndex(getCategory());
	if(row < 0 || column < 0){
		PPCell ppCell = getPPCell();

		throw new InvalidElementException(ppCell);
	}

	Number result = MatrixUtil.getElementAt(matrix, row + 1, column + 1);
	if(result == null){
		throw new InvalidElementException(matrix);
	}

	return product.multiply(result.doubleValue());
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:20,代码来源:GeneralRegressionModelEvaluator.java

示例8: createIdentifierResolver

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
private Function<Integer, String> createIdentifierResolver(final FieldName name, final Table<Integer, FieldName, FieldValue> table){
	Function<Integer, String> function = new Function<Integer, String>(){

		@Override
		public String apply(Integer row){
			FieldValue value = table.get(row, name);
			if(value == null){
				throw new MissingValueException(name);
			}

			return value.asString();
		}
	};

	return function;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:17,代码来源:NearestNeighborModelEvaluator.java

示例9: loadInstanceFlags

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
static
private Map<Integer, BitSet> loadInstanceFlags(NearestNeighborModelEvaluator modelEvaluator){
	Map<Integer, BitSet> result = new LinkedHashMap<>();

	Map<Integer, List<FieldValue>> valueMap = modelEvaluator.getValue(NearestNeighborModelEvaluator.instanceValueCache, createInstanceValueLoader(modelEvaluator));

	Maps.EntryTransformer<Integer, List<FieldValue>, BitSet> transformer = new Maps.EntryTransformer<Integer, List<FieldValue>, BitSet>(){

		@Override
		public BitSet transformEntry(Integer key, List<FieldValue> value){
			return MeasureUtil.toBitSet(value);
		}
	};
	result.putAll(Maps.transformEntries(valueMap, transformer));

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

示例10: evaluate

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
@Override
public FieldValue evaluate(List<FieldValue> arguments){
	checkArguments(arguments, 2, true);

	FieldValue left = arguments.get(0);
	FieldValue right = arguments.get(1);

	// "If one of the input fields of a simple arithmetic function is a missing value, then the result evaluates to missing value"
	if(left == null || right == null){
		return null;
	}

	DataType dataType = TypeUtil.getResultDataType(left.getDataType(), right.getDataType());

	Number result;

	try {
		result = evaluate(left.asNumber(), right.asNumber());
	} catch(ArithmeticException ae){
		throw new UndefinedResultException()
			.initCause(ae);
	}

	return FieldValueUtil.create(dataType, OpType.CONTINUOUS, result);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:26,代码来源:ArithmeticFunction.java

示例11: evaluate

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
@Override
public FieldValue evaluate(List<FieldValue> arguments){
	checkArguments(arguments, 2);

	int length = (arguments.get(0)).asInteger();
	if(length < 0){
		throw new FunctionException(this, "Invalid length value " + length);
	}

	String string = (arguments.get(1)).asString();

	// Trim leading whitespace characters (but keep trailing whitespace characters)
	string = CharMatcher.WHITESPACE.trimLeadingFrom(string);

	// Truncate to a fixed length
	string = string.substring(0, Math.min(length, string.length()));

	// Convert to all uppercase characters
	string = string.toUpperCase();

	return FieldValueUtil.create(DataType.STRING, OpType.CATEGORICAL, string);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:23,代码来源:StringNormalize.java

示例12: parsePairCounts

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
private Map<FieldValue, TargetValueCounts> parsePairCounts(DataType dataType, OpType opType){
	Map<FieldValue, TargetValueCounts> result = new LinkedHashMap<>();

	List<PairCounts> pairCounts = getPairCounts();
	for(PairCounts pairCount : pairCounts){
		FieldValue value = FieldValueUtil.create(dataType, opType, pairCount.getValue());

		TargetValueCounts targetValueCounts = pairCount.getTargetValueCounts();
		if(targetValueCounts == null){
			throw new MissingElementException(pairCount, PMMLElements.PAIRCOUNTS_TARGETVALUECOUNTS);
		}

		result.put(value, targetValueCounts);
	}

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

示例13: evaluate

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
@Override
public FieldValue evaluate(List<FieldValue> arguments){

	if(arguments.size() < 1 || arguments.size() > 2){
		throw new FunctionException(this, "Expected 1 or 2 arguments, got " + arguments.size() + " arguments");
	} // End if

	if(arguments.contains(null)){
		throw new FunctionException(this, "Missing arguments");
	}

	Collection<?> values = FieldValueUtil.getValue(Collection.class, arguments.get(0));

	Boolean biasCorrected = Boolean.FALSE;
	if(arguments.size() > 1){
		biasCorrected = (arguments.get(1)).asBoolean();
	}

	Double result = evaluate(values, biasCorrected);

	return FieldValueUtil.create(DataType.DOUBLE, OpType.CONTINUOUS, result);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:23,代码来源:StandardDeviationFunction.java

示例14: process

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
@Override
public Data process(Data data) {

    for (InputField activeField : activeFields) {

        Object rawValue = data.get(activeField.toString());

        // The raw value is passed through: type conversion or any other transofrmations applied in sklearn
        FieldValue activeValue = activeField.prepare(rawValue);

        FieldName activeFieldName = activeField.getName();

        arguments.put(activeFieldName, activeValue);
    }

    Map<FieldName, ?> results = modelEvaluator.evaluate(arguments);

    Object targetValue = results.get(targetName);

    log.info("Prediction: " + targetValue);
    try {
        data.put(targetName.getValue(), (Serializable) targetValue);
    } catch (ClassCastException e) {
        log.warn("Cannot cast target type to serializable type");
        data.put(targetName.getValue(), targetValue.toString());
    }

    return data;
}
 
开发者ID:fact-project,项目名称:fact-tools,代码行数:30,代码来源:ApplyModel.java

示例15: scoredTuplePerStream

import org.jpmml.evaluator.FieldValue; //导入依赖的package包/类
@Override
public Map<String, List<Object>> scoredTuplePerStream(Tuple input) {
    final Map<FieldName, Object> rawInputs = extractRawInputs(input);
    final Map<FieldName, FieldValue> preProcInputs = preProcessInputs(rawInputs);
    final Map<FieldName, ?> predScores = predictScores(preProcInputs);

    return toStreamLineEvents(predScores, input);
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:9,代码来源:StreamlineJPMMLModelRunner.java


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