Search in sources :

Example 1 with ResultFeatureType

use of org.dmg.pmml.ResultFeatureType 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;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ModelEvaluator(org.jpmml.evaluator.ModelEvaluator) ArrayList(java.util.ArrayList) OutputField(org.dmg.pmml.OutputField) ResultFeatureType(org.dmg.pmml.ResultFeatureType) Evaluator(org.jpmml.evaluator.Evaluator) ModelEvaluator(org.jpmml.evaluator.ModelEvaluator) PMMLManager(org.jpmml.manager.PMMLManager)

Example 2 with ResultFeatureType

use of org.dmg.pmml.ResultFeatureType 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;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ModelEvaluator(org.jpmml.evaluator.ModelEvaluator) ArrayList(java.util.ArrayList) OutputField(org.dmg.pmml.OutputField) ResultFeatureType(org.dmg.pmml.ResultFeatureType) Evaluator(org.jpmml.evaluator.Evaluator) ModelEvaluator(org.jpmml.evaluator.ModelEvaluator) PMMLManager(org.jpmml.manager.PMMLManager)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 ArrayList (java.util.ArrayList)2 OutputField (org.dmg.pmml.OutputField)2 ResultFeatureType (org.dmg.pmml.ResultFeatureType)2 Evaluator (org.jpmml.evaluator.Evaluator)2 ModelEvaluator (org.jpmml.evaluator.ModelEvaluator)2 PMMLManager (org.jpmml.manager.PMMLManager)2