use of org.jpmml.evaluator.ModelEvaluator in project registry by hortonworks.
the class MLModelRegistryService method doGetInputFieldsFromPMMLStream.
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;
}
use of org.jpmml.evaluator.ModelEvaluator in project registry by hortonworks.
the class MLModelRegistryService method doGetOutputFieldsForPMMLStream.
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;
}
use of org.jpmml.evaluator.ModelEvaluator in project streamline by hortonworks.
the class MLModelRegistryService method doGetInputFieldsFromPMMLStream.
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;
}
use of org.jpmml.evaluator.ModelEvaluator in project streamline by hortonworks.
the class MLModelRegistryService method doGetOutputFieldsForPMMLStream.
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;
}
use of org.jpmml.evaluator.ModelEvaluator in project storm by apache.
the class JpmmlFactory method newEvaluator.
// ================== Evaluator ==================
/**
* Creates a new {@link Evaluator} object representing the PMML model defined in the {@link PMML} argument.
*/
public static Evaluator newEvaluator(PMML pmml) {
Objects.requireNonNull(pmml);
final PMMLManager pmmlManager = new PMMLManager(pmml);
return (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
}
Aggregations