• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PMMLManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: doGetOutputFieldsForPMMLStream

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


示例2: instantiateJPMMLModel

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


示例3: doGetOutputFieldsForPMMLStream

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


示例4: setPredictiveModelFile

import org.jpmml.manager.PMMLManager; //导入依赖的package包/类
public void setPredictiveModelFile(PredictiveModelFile file) {
this.modelFile = file;

try {
    this.pmml = IOUtil.unmarshal(this.modelFile.getFile());
} catch (Exception e) {
    log.log(Level.SEVERE, e.getMessage());
    return;
}
	
this.pmmlManager = new PMMLManager(this.pmml);
	
// Load the default model
this.evaluator = (Evaluator)pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
	
  }
 
开发者ID:mschachtel,项目名称:cloutree-modelevaluator,代码行数:17,代码来源:PmmlPredictiveModel.java


示例5: doGetInputFieldsFromPMMLStream

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


示例6: doGetInputFieldsFromPMMLStream

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


示例7: createEvaluator

import org.jpmml.manager.PMMLManager; //导入依赖的package包/类
private static Evaluator createEvaluator(String filePath) throws SAXException, JAXBException, IOException{
	InputStream is = new FileInputStream(new File(filePath));
	PMML pmml;
	try {
		Source source = ImportFilter.apply(new InputSource(is));
		pmml = JAXBUtil.unmarshalPMML(source);
	} finally {
		is.close();
	}
	PMMLManager pmmlManager = new PMMLManager(pmml);
	return (Evaluator)pmmlManager.getModelManager(ModelEvaluatorFactory.getInstance());		
}
 
开发者ID:selvinsource,项目名称:spark-pmml-exporter-validator,代码行数:13,代码来源:SparkPMMLExporterValidator.java


示例8: initialize

import org.jpmml.manager.PMMLManager; //导入依赖的package包/类
private void initialize(Schema inputSchema) throws IOException, SAXException, JAXBException {

		this.inputTupleSchema = inputSchema;

		// and, initialize aliasMap:
		if (this.aliasMap == null) {
			this.aliasMap = new HashMap<String,Integer>();
			for (String alias : this.inputTupleSchema.getAliases()) {
				this.aliasMap.put(alias,this.inputTupleSchema.getPosition(alias));		// something to cleanup
			}
		}

		// Get PMML Object
		PMML pmml = null;
		try {
			
			/*
			 * TODO: Make this more robust. Specifically, Angela Ho wanted to refernce a file in the distributed
			 * 		 cache directly.  Obviously, my code doesn't support this, because it would try to open
			 * 	     the file with the IOUtil Java object, as opposed to the hadoop.fs.Path object.
			 * 
			 * TODO: This try/catch block is a hack for:
			 * 		(1) checking if execution is being done on "back-end."  A check for back-end can be done with 
			 * 			UDFContext.getUDFContext().isFrontend() BUT this does not resolve problems with local-mode.
			 * 		(2) enables testing in local-mode without failing unit tests.
			 */
			
			// Try reading file from distributed cache.
    		pmml = IOUtil.unmarshal(new File("./"+this.modelName));
    		System.err.println("Read model from distributed cache!");
    		
		} catch (Throwable t) {
			// If not on the back-end... (and distributed cache not available) ...
			
			if (this.modelPath.toLowerCase().startsWith("s3n://") || this.modelPath.toLowerCase().startsWith("s3://")) {
				// ... read from S3.
				Path path = new Path(this.modelPath);
				FileSystem fs = path.getFileSystem(new Configuration());
				FSDataInputStream in = fs.open(path);
				pmml = IOUtil.unmarshal(in);
	    		System.err.println("Read model from s3!");

			} else {
				// ... read from local file.
				pmml = IOUtil.unmarshal(new File(this.modelPath));
	    		System.err.println("Read model from local disk!");
			}

		}

		// Initialize the pmmlManager
		PMMLManager pmmlManager = new PMMLManager(pmml);
		
		// Initialize the PMML Model Manager
		ModelManager<?> modelManager = pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());

		this.evaluator 		 = (Evaluator)modelManager;			// Model Evaluator
		this.activeFields 	 = evaluator.getActiveFields();		// input columns
		this.predictedFields = evaluator.getPredictedFields();	// predicted columns
		this.outputFields 	 = evaluator.getOutputFields();		// derived output columns (based on predicted columns)

	}
 
开发者ID:Netflix,项目名称:Surus,代码行数:63,代码来源:ScorePMML.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SVGResource类代码示例发布时间:2022-05-23
下一篇:
Java ActionEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap