當前位置: 首頁>>代碼示例>>Java>>正文


Java FieldValueUtil類代碼示例

本文整理匯總了Java中org.jpmml.evaluator.FieldValueUtil的典型用法代碼示例。如果您正苦於以下問題:Java FieldValueUtil類的具體用法?Java FieldValueUtil怎麽用?Java FieldValueUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FieldValueUtil類屬於org.jpmml.evaluator包,在下文中一共展示了FieldValueUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的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

示例2: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的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

示例3: parsePairCounts

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的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

示例4: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的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

示例5: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> values){
	checkArguments(values, 2);

	String id = (values.get(0)).asString();

	IMolecularDescriptor molecularDescriptor = getMolecularDescriptor(id);
	if(molecularDescriptor == null){
		throw new FunctionException(this, "No descriptor for \"" + id + "\"");
	}

	String structure = (values.get(1)).asString();

	IAtomContainer atomContainer = getAtomContainer(structure);
	if(atomContainer == null){
		throw new FunctionException(this, "No atom container for \"" + structure + "\"");
	}

	DescriptorValue descriptorValue;

	try {
		descriptorValue = getDescriptorValue(molecularDescriptor, atomContainer);
	} catch(Exception e){
		throw new FunctionException(this, "Failed to get or calculate descriptor value: " + e.toString());
	}

	Object result = getResult(id, molecularDescriptor.getDescriptorNames(), descriptorValue.getValue());

	return FieldValueUtil.create(null, OpType.CONTINUOUS, result);
}
 
開發者ID:vruusmann,項目名稱:qsar.io,代碼行數:31,代碼來源:CDKDescriptorFunction.java

示例6: load

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
@Override
public List<FieldValue> load(Cluster cluster){
	Array array = cluster.getArray();

	List<? extends Number> values = ArrayUtil.asNumberList(array);

	return ImmutableList.copyOf(FieldValueUtil.createAll(null, OpType.CONTINUOUS, values));
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:9,代碼來源:ClusteringModelEvaluator.java

示例7: parseCategories

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
private List<FieldValue> parseCategories(final DataType dataType, final OpType opType){
	List<String> categories = getCategories();

	Function<String, FieldValue> function = new Function<String, FieldValue>(){

		@Override
		public FieldValue apply(String value){
			return FieldValueUtil.create(dataType, opType, value);
		}
	};

	return Lists.transform(categories, function);
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:14,代碼來源:GeneralRegressionModelEvaluator.java

示例8: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> arguments){
	checkArguments(arguments, 2);

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

	Boolean result = evaluate((left).compareToValue(right));

	return FieldValueUtil.create(DataType.BOOLEAN, OpType.CATEGORICAL, result);
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:12,代碼來源:ComparisonFunction.java

示例9: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> arguments){
	checkArguments(arguments, 2);

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

	Boolean result = evaluate((left).equalsValue(right));

	return FieldValueUtil.create(DataType.BOOLEAN, OpType.CATEGORICAL, result);
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:12,代碼來源:EqualityFunction.java

示例10: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> arguments){
	StorelessUnivariateStatistic statistic = createStatistic();

	DataType dataType = null;

	// "Missing values in the input to an aggregate function are simply ignored"
	Iterable<FieldValue> values = Iterables.filter(arguments, Predicates.notNull());
	for(FieldValue value : values){
		statistic.increment((value.asNumber()).doubleValue());

		if(dataType != null){
			dataType = TypeUtil.getResultDataType(dataType, value.getDataType());
		} else

		{
			dataType = value.getDataType();
		}
	}

	// "If all inputs are missing, then the result evaluates to a missing value"
	if(statistic.getN() == 0){
		return null;
	}

	Double result = statistic.getResult();

	return FieldValueUtil.create(getResultType(dataType), OpType.CONTINUOUS, result);
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:30,代碼來源:AggregateFunction.java

示例11: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> arguments){
	checkVariableArguments(arguments, 2);

	Boolean result = (arguments.get(0)).asBoolean();

	for(int i = 1; i < arguments.size(); i++){
		result = evaluate(result, (arguments.get(i)).asBoolean());
	}

	return FieldValueUtil.create(DataType.BOOLEAN, OpType.CATEGORICAL, result);
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:13,代碼來源:BinaryBooleanFunction.java

示例12: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> arguments){
	checkArguments(arguments, 1);

	// Angle in radians
	Number angle = (arguments.get(0)).asNumber();

	Double result = evaluate(angle);
	if(result.isNaN()){
		throw new NaNResultException();
	}

	return FieldValueUtil.create(DataType.DOUBLE, OpType.CONTINUOUS, result);
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:15,代碼來源:TrigonometricFunction.java

示例13: evaluate

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
static
private String evaluate(int length, String string){
	StringNormalize stringNormalize = new StringNormalize();

	List<FieldValue> arguments = Arrays.asList(FieldValueUtil.create(DataType.INTEGER, OpType.CONTINUOUS, length), FieldValueUtil.create(DataType.STRING, OpType.CATEGORICAL, string));

	return (stringNormalize.evaluate(arguments)).asString();
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:9,代碼來源:StringNormalizeTest.java

示例14: getValue

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
@Override
public FieldValue getValue(DataType dataType, OpType opType){

	if(this.parsedValue == null){
		this.parsedValue = FieldValueUtil.create(dataType, opType, getValue());
	}

	return this.parsedValue;
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:10,代碼來源:RichPPCell.java

示例15: parseBaselineStrata

import org.jpmml.evaluator.FieldValueUtil; //導入依賴的package包/類
private Map<FieldValue, BaselineStratum> parseBaselineStrata(DataType dataType, OpType opType){
	Map<FieldValue, BaselineStratum> result = new LinkedHashMap<>();

	List<BaselineStratum> baselineStrata = getBaselineStrata();
	for(BaselineStratum baselineStratum : baselineStrata){
		FieldValue value = FieldValueUtil.create(dataType, opType, baselineStratum.getValue());

		result.put(value, baselineStratum);
	}

	return result;
}
 
開發者ID:jpmml,項目名稱:jpmml-evaluator,代碼行數:13,代碼來源:RichBaseCumHazardTables.java


注:本文中的org.jpmml.evaluator.FieldValueUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。