本文整理汇总了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;未经允许,请勿转载。 |
请发表评论