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


Java Evaluator.getActiveFields方法代码示例

本文整理汇总了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()]);
}
 
开发者ID:jeremyore,项目名称:spark-pmml-import,代码行数:18,代码来源:PMMLTransformer.java

示例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()]);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator-spark,代码行数:18,代码来源:PMMLTransformer.java

示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-pig,代码行数:24,代码来源:PMMLUtil.java

示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-postgresql,代码行数:23,代码来源:PMMLUtil.java

示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-postgresql,代码行数:22,代码来源:PMMLUtil.java

示例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;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:10,代码来源:MLModelRegistryService.java

示例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;
}
 
开发者ID:DhruvKumar,项目名称:iot-masterclass,代码行数:13,代码来源:SparkPredictionBolt.java

示例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;
}
 
开发者ID:DhruvKumar,项目名称:iot-masterclass,代码行数:13,代码来源:PredictionBoltJPMML.java

示例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;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:10,代码来源:MLModelRegistryService.java

示例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};
}
 
开发者ID:jpmml,项目名称:jpmml-hive,代码行数:35,代码来源:PMMLUtil.java

示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-hive,代码行数:34,代码来源:PMMLUtil.java

示例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);
}
 
开发者ID:jpmml,项目名称:jpmml-storm,代码行数:37,代码来源:PMMLBolt.java

示例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);	
	
}
 
开发者ID:selvinsource,项目名称:spark-pmml-exporter-validator,代码行数:27,代码来源:SparkPMMLExporterValidator.java

示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-hive,代码行数:24,代码来源:PMMLUtil.java


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