本文整理匯總了Java中org.jpmml.evaluator.FieldValueUtil.create方法的典型用法代碼示例。如果您正苦於以下問題:Java FieldValueUtil.create方法的具體用法?Java FieldValueUtil.create怎麽用?Java FieldValueUtil.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jpmml.evaluator.FieldValueUtil
的用法示例。
在下文中一共展示了FieldValueUtil.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: evaluate
import org.jpmml.evaluator.FieldValueUtil; //導入方法依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> arguments){
checkArguments(arguments, 2);
Collection<?> values = FieldValueUtil.getValue(Collection.class, arguments.get(0));
int percentile = (arguments.get(1)).asInteger();
if(percentile < 1 || percentile > 100){
throw new FunctionException(this, "Invalid percentile value " + percentile + ". Must be greater than 0 and equal or less than 100");
}
Double result = evaluate(values, percentile);
return FieldValueUtil.create(DataType.DOUBLE, OpType.CONTINUOUS, result);
}
示例9: 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;
}
示例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);
}
示例11: 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);
}
示例12: 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;
}
示例13: prepare
import org.jpmml.evaluator.FieldValueUtil; //導入方法依賴的package包/類
@Override
public FieldValue prepare(String value){
return FieldValueUtil.create(DataType.STRING, OpType.CATEGORICAL, value);
}
示例14: evaluate
import org.jpmml.evaluator.FieldValueUtil; //導入方法依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> arguments){
checkVariableArguments(arguments, 2);
FieldValue value = arguments.get(0);
List<FieldValue> values = arguments.subList(1, arguments.size());
Boolean result = evaluate(value.indexInValues(values));
return FieldValueUtil.create(DataType.BOOLEAN, OpType.CATEGORICAL, result);
}
示例15: evaluate
import org.jpmml.evaluator.FieldValueUtil; //導入方法依賴的package包/類
@Override
public FieldValue evaluate(List<FieldValue> arguments){
checkArguments(arguments, 1, true);
FieldValue value = arguments.get(0);
Boolean result = evaluate(value);
return FieldValueUtil.create(DataType.BOOLEAN, OpType.CATEGORICAL, result);
}