本文整理汇总了Java中org.jpmml.evaluator.Evaluator.getActiveFields方法的典型用法代码示例。如果您正苦于以下问题:Java Evaluator.getActiveFields方法的具体用法?Java Evaluator.getActiveFields怎么用?Java Evaluator.getActiveFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jpmml.evaluator.Evaluator
的用法示例。
在下文中一共展示了Evaluator.getActiveFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputCols
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
public String[] getInputCols() {
Evaluator evaluator = getEvaluator();
List<InputField> inputFields = evaluator.getActiveFields();
Function<InputField, String> function = new Function<InputField, String>() {
@Override
public String apply(InputField inputField) {
return (inputField.getName()).getValue();
}
};
List<String> values = Lists.newArrayList(Lists.transform(inputFields, function));
return values.toArray(new String[values.size()]);
}
示例2: getInputCols
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
public String[] getInputCols(){
Evaluator evaluator = getEvaluator();
List<InputField> inputFields = evaluator.getActiveFields();
Function<InputField, String> function = new Function<InputField, String>(){
@Override
public String apply(InputField inputField){
return (inputField.getName()).getValue();
}
};
List<String> values = Lists.newArrayList(Lists.transform(inputFields, function));
return values.toArray(new String[values.size()]);
}
示例3: loadPrimitiveList
import org.jpmml.evaluator.Evaluator; //导入方法依赖的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;
}
示例4: loadStruct
import org.jpmml.evaluator.Evaluator; //导入方法依赖的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;
}
示例5: loadScalarList
import org.jpmml.evaluator.Evaluator; //导入方法依赖的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;
}
示例6: doGetInputFieldsFromPMMLStream
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
private List<MLModelField> doGetInputFieldsFromPMMLStream(String pmmlContents) throws SAXException, JAXBException {
final List<MLModelField> fieldNames = new ArrayList<>();
PMMLManager pmmlManager = new PMMLManager(IOUtil.unmarshal(new ByteArrayInputStream(pmmlContents.getBytes())));
Evaluator modelEvaluator = (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
for (FieldName predictedField : modelEvaluator.getActiveFields()) {
fieldNames.add(getModelField(modelEvaluator.getDataField(predictedField)));
}
return fieldNames;
}
示例7: prepareArguments
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
private Map<FieldName, ?> prepareArguments(Evaluator evaluator, double[] inputValues) {
Map<FieldName, Object> arguments = new LinkedHashMap<FieldName, Object>();
List<FieldName> activeFields = evaluator.getActiveFields();
// loop over and prepare each argument
int idx = 0;
for (FieldName activeField : activeFields) {
DataField dataField = evaluator.getDataField(activeField);
arguments.put(activeField, evaluator.prepare(activeField, inputValues[idx]));
idx++;
}
return arguments;
}
示例8: prepareArguments
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
public Map<FieldName, ?> prepareArguments(Evaluator evaluator, double[] inputValues) {
Map<FieldName, Object> arguments = new LinkedHashMap<FieldName, Object>();
List<FieldName> activeFields = evaluator.getActiveFields();
// loop over and prepare each argument
int idx = 0;
for (FieldName activeField : activeFields) {
DataField dataField = evaluator.getDataField(activeField);
arguments.put(activeField, evaluator.prepare(activeField, inputValues[idx]));
idx++;
}
return arguments;
}
示例9: doGetInputFieldsFromPMMLStream
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
private List<MLModelField> doGetInputFieldsFromPMMLStream(String pmmlContents) throws SAXException, JAXBException, UnsupportedEncodingException {
final List<MLModelField> fieldNames = new ArrayList<>();
PMMLManager pmmlManager = new PMMLManager(IOUtil.unmarshal(new ByteArrayInputStream(pmmlContents.getBytes("UTF-8"))));
Evaluator modelEvaluator = (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
for (FieldName predictedField: modelEvaluator.getActiveFields()) {
fieldNames.add(getModelField(modelEvaluator.getDataField(predictedField)));
}
return fieldNames;
}
示例10: initializeStruct
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
static
private ObjectInspector[] initializeStruct(Evaluator evaluator, ObjectInspector inspector) throws UDFArgumentException {
StructObjectInspector structInspector = (StructObjectInspector)inspector;
List<FieldName> activeFields = evaluator.getActiveFields();
for(FieldName activeField : activeFields){
DataField field = evaluator.getDataField(activeField);
StructField structField;
try {
structField = structInspector.getStructFieldRef(activeField.getValue());
} catch(Exception e){
throw new UDFArgumentTypeException(0, "Missing struct field \"" + activeField.getValue() + "\"");
}
ObjectInspector structFieldInspector = structField.getFieldObjectInspector();
ObjectInspector.Category structFieldCategory = structFieldInspector.getCategory();
switch(structFieldCategory){
case PRIMITIVE:
break;
default:
throw new UDFArgumentTypeException(0, "Struct field \"" + activeField.getValue() + "\": Expected " + ObjectInspector.Category.PRIMITIVE + " type, got " + structFieldCategory + " type");
}
DataType dataType = getDataType(structFieldInspector);
if(!isConvertible(dataType, field.getDataType())){
throw new UDFArgumentTypeException(0, "Struct field \"" + activeField.getValue() + "\": Cannot convert " + dataType + " to " + field.getDataType());
}
}
return new ObjectInspector[]{structInspector};
}
示例11: initializePrimitiveList
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
static
private ObjectInspector[] initializePrimitiveList(Evaluator evaluator, ObjectInspector[] inspectors) throws UDFArgumentException {
List<FieldName> activeFields = evaluator.getActiveFields();
if(inspectors.length != activeFields.size()){
throw new UDFArgumentLengthException("Expected " + activeFields.size() + " arguments, got " + inspectors.length + " arguments");
}
int i = 0;
for(FieldName activeField : activeFields){
DataField field = evaluator.getDataField(activeField);
ObjectInspector inspector = inspectors[i];
ObjectInspector.Category category = inspector.getCategory();
switch(category){
case PRIMITIVE:
break;
default:
throw new UDFArgumentTypeException(i, "Expected " + ObjectInspector.Category.PRIMITIVE + " type, got " + category + " type");
}
DataType dataType = getDataType(inspector);
if(!isConvertible(dataType, field.getDataType())){
throw new UDFArgumentTypeException(i, "Cannot convert " + dataType + " to " + field.getDataType());
}
i++;
}
return inspectors;
}
示例12: execute
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
@Override
public void execute(Tuple tuple){
Evaluator evaluator = getEvaluator();
Map<FieldName, FieldValue> arguments = new LinkedHashMap<>();
List<FieldName> activeFields = evaluator.getActiveFields();
for(FieldName activeField : activeFields){
FieldValue value = EvaluatorUtil.prepare(evaluator, activeField, tuple.getValueByField(activeField.getValue()));
arguments.put(activeField, value);
}
Map<FieldName, ?> result = evaluator.evaluate(arguments);
Values values = new Values();
List<FieldName> targetFields = evaluator.getTargetFields();
for(FieldName targetField : targetFields){
Object targetValue = result.get(targetField);
values.add(EvaluatorUtil.decode(targetValue));
}
List<FieldName> outputFields = evaluator.getOutputFields();
for(FieldName outputField : outputFields){
Object outputValue = result.get(outputField);
values.add(outputValue);
}
OutputCollector collector = getCollector();
collector.emit(tuple, values);
collector.ack(tuple);
}
示例13: evaluate
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
@ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT)
public Object evaluate(Message<?> input) {
Model model = selectModel(input);
Evaluator evaluator = modelEvaluatorFactory.newModelManager(pmml, model);
Map<FieldName, FieldValue> arguments = new LinkedHashMap<>();
List<FieldName> activeFields = evaluator.getActiveFields();
for (FieldName activeField : activeFields) {
// The raw (ie. user-supplied) value could be any Java primitive value
Object rawValue = resolveActiveValue(input, activeField.getValue());
// The raw value is passed through:
// 1) outlier treatment,
// 2) missing value treatment,
// 3) invalid value treatment
// and 4) type conversion
FieldValue activeValue = evaluator.prepare(activeField, rawValue);
arguments.put(activeField, activeValue);
}
Map<FieldName, ?> results = evaluator.evaluate(arguments);
MutableMessage<?> result = convertToMutable(input);
for (Map.Entry<FieldName, ?> entry : results.entrySet()) {
String fieldName = null;
if (entry.getKey()==null)
fieldName = DEFAULT_OUTPUT_FIELD;
else
fieldName = entry.getKey().getValue();
Expression expression = properties.getOutputs().get(fieldName);
if (expression == null) {
expression = spelExpressionParser.parseExpression("payload." + fieldName);
}
if (logger.isDebugEnabled()) {
logger.debug("Setting result field named " + fieldName + " using SpEL[" + expression + " = "
+ entry.getValue() + "]");
}
expression.setValue(evaluationContext, result, entry.getValue());
}
return result;
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:49,代码来源:PmmlProcessorConfiguration.java
示例14: evaluate
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> T evaluate(Double[] values, Evaluator evaluator){
List<FieldName> activeFields = evaluator.getActiveFields();
Map<FieldName, FieldValue> arguments = new LinkedHashMap<FieldName, FieldValue>();
int i = 0;
for(FieldName activeField : activeFields){
// The raw (ie. user-supplied) value could be any Java primitive value
Object rawValue = values[i];
// The raw value is passed through: 1) outlier treatment, 2) missing value treatment, 3) invalid value treatment and 4) type conversion
FieldValue activeValue = evaluator.prepare(activeField, rawValue);
arguments.put(activeField, activeValue);
i++;
}
Map<FieldName, ?> results = evaluator.evaluate(arguments);
FieldName targetName = evaluator.getTargetField();
return (T)results.get(targetName);
}
示例15: loadStruct
import org.jpmml.evaluator.Evaluator; //导入方法依赖的package包/类
static
private Map<FieldName, FieldValue> loadStruct(Evaluator evaluator, ObjectInspector inspector, GenericUDF.DeferredObject object) throws HiveException {
Map<FieldName, FieldValue> result = Maps.newLinkedHashMap();
StructObjectInspector structInspector = (StructObjectInspector)inspector;
Object structObject = object.get();
List<FieldName> activeFields = evaluator.getActiveFields();
for(FieldName activeField : activeFields){
StructField structField = structInspector.getStructFieldRef(activeField.getValue());
PrimitiveObjectInspector primitiveObjectInspector = (PrimitiveObjectInspector)structField.getFieldObjectInspector();
Object primitiveObject = structInspector.getStructFieldData(structObject, structField);
FieldValue value = EvaluatorUtil.prepare(evaluator, activeField, primitiveObjectInspector.getPrimitiveJavaObject(primitiveObject));
result.put(activeField, value);
}
return result;
}