use of org.dmg.pmml.OutputField in project jpmml-sparkml by jpmml.
the class MultilayerPerceptronClassificationModelConverter method registerOutputFields.
@Override
public List<OutputField> registerOutputFields(Label label, SparkMLEncoder encoder) {
MultilayerPerceptronClassificationModel model = getTransformer();
List<OutputField> result = super.registerOutputFields(label, encoder);
if (!(model instanceof HasProbabilityCol)) {
CategoricalLabel categoricalLabel = (CategoricalLabel) label;
result = new ArrayList<>(result);
result.addAll(ModelUtil.createProbabilityFields(DataType.DOUBLE, categoricalLabel.getValues()));
}
return result;
}
use of org.dmg.pmml.OutputField in project jpmml-sparkml by jpmml.
the class RegressionModelConverter method registerOutputFields.
@Override
public List<OutputField> registerOutputFields(Label label, SparkMLEncoder encoder) {
T model = getTransformer();
String predictionCol = model.getPredictionCol();
OutputField predictedField = ModelUtil.createPredictedField(FieldName.create(predictionCol), label.getDataType(), OpType.CONTINUOUS);
encoder.putOnlyFeature(predictionCol, new ContinuousFeature(encoder, predictedField.getName(), predictedField.getDataType()));
return Collections.singletonList(predictedField);
}
use of org.dmg.pmml.OutputField in project jpmml-sparkml by jpmml.
the class ClusteringModelConverter method registerOutputFields.
@Override
public List<OutputField> registerOutputFields(Label label, SparkMLEncoder encoder) {
T model = getTransformer();
String predictionCol = model.getPredictionCol();
OutputField predictedField = ModelUtil.createPredictedField(FieldName.create(predictionCol), DataType.STRING, OpType.CATEGORICAL);
Feature feature = new Feature(encoder, predictedField.getName(), predictedField.getDataType()) {
@Override
public ContinuousFeature toContinuousFeature() {
throw new UnsupportedOperationException();
}
};
encoder.putOnlyFeature(predictionCol, feature);
return Collections.singletonList(predictedField);
}
use of org.dmg.pmml.OutputField 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.dmg.pmml.OutputField in project drools by kiegroup.
the class PMMLModelTestUtils method getRandomOutputField.
public static OutputField getRandomOutputField() {
FieldName fieldName = FieldName.create(RandomStringUtils.random(6, true, false));
OutputField toReturn = new OutputField();
toReturn.setName(fieldName);
toReturn.setOpType(getRandomOpType());
toReturn.setDataType(getRandomDataType());
toReturn.setValue(getRandomValue(toReturn.getDataType()));
fieldName = FieldName.create(RandomStringUtils.random(6, true, false));
toReturn.setTargetField(fieldName);
toReturn.setResultFeature(getRandomResultFeature());
toReturn.setExpression(getRandomConstant());
return toReturn;
}
Aggregations