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


Java Evaluator类代码示例

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


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

示例1: init

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
@Override
public StructField init(Evaluator evaluator){
	OutputField field = getField();

	DataType dataType = field.getDataType();
	if(dataType == null){

		try {
			dataType = OutputUtil.getDataType(field.getOutputField(), (ModelEvaluator<?>)evaluator);

			this.formatString = false;
		} catch(PMMLException pe){
			dataType = DataType.STRING;

			this.formatString = true;
		}
	}

	return DataTypes.createStructField(getColumnName(), SchemaUtil.translateDataType(dataType), false);
}
 
开发者ID:jeremyore,项目名称:spark-pmml-import,代码行数:21,代码来源:OutputColumnProducer.java

示例2: doGetOutputFieldsForPMMLStream

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
private List<MLModelField> doGetOutputFieldsForPMMLStream(String pmmlContents) throws SAXException, JAXBException {
    List<MLModelField> fieldNames = new ArrayList<>();
    PMMLManager pmmlManager = new PMMLManager(IOUtil.unmarshal(new ByteArrayInputStream(pmmlContents.getBytes())));
    Evaluator modelEvaluator = (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
    modelEvaluator.getPredictedFields().forEach((f) -> fieldNames.add(getModelField(modelEvaluator.getDataField(f))));

    modelEvaluator.getOutputFields().forEach((f) -> {
        OutputField outputField = modelEvaluator.getOutputField(f);
        ResultFeatureType resultFeatureType = outputField.getFeature();
        if (resultFeatureType != ResultFeatureType.PREDICTED_VALUE &&
                resultFeatureType != ResultFeatureType.PREDICTED_DISPLAY_VALUE) {
            fieldNames.add(getModelField(outputField));
        }
    });

    return fieldNames;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:18,代码来源:MLModelRegistryService.java

示例3: instantiateJPMMLModel

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
private Evaluator instantiateJPMMLModel() {
  PMML pmml = null;
  try {
    pmml = IOUtil.unmarshal(Launcher.class.getResource("/predictionModel-PMML.xml").openStream());
  } catch (Exception e) {
    e.printStackTrace();
  }
  PMMLManager pmmlManager = new PMMLManager(pmml);
  Evaluator evaluator = (Evaluator) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
  return evaluator;
}
 
开发者ID:DhruvKumar,项目名称:iot-lab,代码行数:12,代码来源:SparkPredictionBolt.java

示例4: doGetOutputFieldsForPMMLStream

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
private List<MLModelField> doGetOutputFieldsForPMMLStream(String pmmlContents) throws SAXException, JAXBException, UnsupportedEncodingException {
    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());
    modelEvaluator.getPredictedFields().forEach((f) -> fieldNames.add(getModelField(modelEvaluator.getDataField(f))));

    modelEvaluator.getOutputFields().forEach((f) -> {
        OutputField outputField = modelEvaluator.getOutputField(f);
        ResultFeatureType resultFeatureType = outputField.getFeature();
        if (resultFeatureType != ResultFeatureType.PREDICTED_VALUE &&
                resultFeatureType != ResultFeatureType.PREDICTED_DISPLAY_VALUE) {
            fieldNames.add(getModelField(outputField));
        }
    });

    return fieldNames;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:18,代码来源:MLModelRegistryService.java

示例5: 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

示例6: onCreate

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState){
	super.onCreate(savedInstanceState);

	setContentView(R.layout.main);

	Button loadButton = (Button)findViewById(R.id.loadButton);

	View.OnClickListener onClickListener = new View.OnClickListener(){

		@Override
		public void onClick(View view){
			Evaluator evaluator;

			try {
				evaluator = createEvaluator();
			} catch(Exception e){
				throw new RuntimeException(e);
			}

			showEvaluatorDialog(evaluator);
		}
	};
	loadButton.setOnClickListener(onClickListener);
}
 
开发者ID:jpmml,项目名称:jpmml-android,代码行数:26,代码来源:MainActivity.java

示例7: showEvaluatorDialog

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
private void showEvaluatorDialog(Evaluator evaluator){
	List<FieldName> activeFields = getNames(evaluator.getActiveFields());
	List<FieldName> targetFields = getNames(evaluator.getTargetFields());
	List<FieldName> outputFields = getNames(evaluator.getOutputFields());

	StringBuilder sb = new StringBuilder();

	sb.append("Active fields: ").append(activeFields);
	sb.append("\n");
	sb.append("Target fields: ").append(targetFields);
	sb.append("\n");
	sb.append("Output fields: ").append(outputFields);

	TextView textView = new TextView(this);
	textView.setText(sb.toString());

	Dialog dialog = new Dialog(this);
	dialog.setContentView(textView);
	dialog.show();
}
 
开发者ID:jpmml,项目名称:jpmml-android,代码行数:21,代码来源:MainActivity.java

示例8: 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

示例9: loadArguments

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

示例10: 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

示例11: storeResult

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
static
private Tuple storeResult(Evaluator evaluator, Map<FieldName, ?> result){
	List<Object> values = Lists.newArrayList();

	List<FieldName> targetFields = evaluator.getTargetFields();
	for(FieldName targetField : targetFields){
		values.add(EvaluatorUtil.decode(result.get(targetField)));
	}

	List<FieldName> outputFields = evaluator.getOutputFields();
	for(FieldName outputField : outputFields){
		values.add(result.get(outputField));
	}

	TupleFactory tupleFactory = TupleFactory.getInstance();

	return tupleFactory.newTuple(values);
}
 
开发者ID:jpmml,项目名称:jpmml-pig,代码行数:19,代码来源:PMMLUtil.java

示例12: evaluateKMeansModel

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private static void evaluateKMeansModel(Evaluator evaluator){
	
	ClusteringModelEvaluator cluster = (ClusteringModelEvaluator)evaluator;
	
	System.out.println("Cluster centers: ");
    Iterator it = cluster.getEntityRegistry().entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry)it.next();
        System.out.println(pairs.getKey() + " = " + ((Cluster)pairs.getValue()).getArray().getValue());
    }
    
    ClassificationMap map;
	
	map = SparkPMMLExporterValidator.<ClassificationMap>evaluate(new Double[]{5.1,3.5,1.4,0.2}, evaluator);
	System.out.println("Cluster assigned to new Double[]{5.1,3.5,1.4,0.2}: " + map.getResult());
	map = SparkPMMLExporterValidator.<ClassificationMap>evaluate(new Double[]{5.9,3.0,5.1,1.8}, evaluator);
	System.out.println("Cluster assigned to new Double[]{5.9,3.0,5.1,1.8}: " + map.getResult());
	
}
 
开发者ID:selvinsource,项目名称:spark-pmml-exporter-validator,代码行数:21,代码来源:SparkPMMLExporterValidator.java

示例13: initializeArguments

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
/**
 * @see #initializeSimpleResult(Class)
 * @see #initializeComplexResult(Class)
 */
static
public ObjectInspector[] initializeArguments(Class<? extends GenericUDF> clazz, ObjectInspector[] inspectors) throws UDFArgumentException {
	Evaluator evaluator = getEvaluator(clazz);

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

		ObjectInspector.Category category = inspector.getCategory();
		switch(category){
			case STRUCT:
				return initializeStruct(evaluator, inspector);
			default:
				return initializePrimitiveList(evaluator, inspectors);
		}
	}

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

示例14: loadArguments

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

示例15: storeStruct

import org.jpmml.evaluator.Evaluator; //导入依赖的package包/类
static
private Object[] storeStruct(Evaluator evaluator, Map<FieldName, ?> result){
	List<Object> resultStruct = Lists.newArrayList();

	List<FieldName> targetFields = evaluator.getTargetFields();
	for(FieldName targetField : targetFields){
		resultStruct.add(EvaluatorUtil.decode(result.get(targetField)));
	}

	List<FieldName> outputFields = evaluator.getOutputFields();
	for(FieldName outputField : outputFields){
		resultStruct.add(result.get(outputField));
	}

	return resultStruct.toArray(new Object[resultStruct.size()]);
}
 
开发者ID:jpmml,项目名称:jpmml-hive,代码行数:17,代码来源:PMMLUtil.java


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