org.dmg.pmml.Output Java Examples
The following examples show how to use
org.dmg.pmml.Output.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModelManager.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 6 votes |
@Override public Set<ResultFeature> load(Output output){ Set<ResultFeature> result = EnumSet.noneOf(ResultFeature.class); List<org.dmg.pmml.OutputField> pmmlOutputFields = output.getOutputFields(); for(org.dmg.pmml.OutputField pmmlOutputField : pmmlOutputFields){ String segmentId = pmmlOutputField.getSegmentId(); if(segmentId != null){ continue; } result.add(pmmlOutputField.getResultFeature()); } return Sets.immutableEnumSet(result); }
Example #2
Source File: MapHolderParser.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 6 votes |
@Override public VisitorAction visit(Output output){ if(output.hasOutputFields()){ List<OutputField> outputFields = output.getOutputFields(); for(ListIterator<OutputField> it = outputFields.listIterator(); it.hasNext(); ){ OutputField outputField = it.next(); if(outputField.hasValues()){ it.set(new RichOutputField(outputField)); } } } return super.visit(output); }
Example #3
Source File: MiningModelEvaluator.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 6 votes |
@Override public Map<String, Set<ResultFeature>> load(Output output){ Map<String, Set<ResultFeature>> result = new LinkedHashMap<>(); List<org.dmg.pmml.OutputField> pmmlOutputFields = output.getOutputFields(); for(org.dmg.pmml.OutputField pmmlOutputField : pmmlOutputFields){ String segmentId = pmmlOutputField.getSegmentId(); if(segmentId == null){ continue; } Set<ResultFeature> resultFeatures = result.get(segmentId); if(resultFeatures == null){ resultFeatures = EnumSet.noneOf(ResultFeature.class); result.put(segmentId, resultFeatures); } resultFeatures.add(pmmlOutputField.getResultFeature()); } result.replaceAll((key, value) -> Sets.immutableEnumSet(value)); return ImmutableMap.copyOf(result); }
Example #4
Source File: OneClassSVM.java From jpmml-sklearn with GNU Affero General Public License v3.0 | 5 votes |
@Override public SupportVectorMachineModel encodeModel(Schema schema){ Transformation outlier = new OutlierTransformation(){ @Override public Expression createExpression(FieldRef fieldRef){ return PMMLUtil.createApply(PMMLFunctions.LESSOREQUAL, fieldRef, PMMLUtil.createConstant(0d)); } }; SupportVectorMachineModel supportVectorMachineModel = super.encodeModel(schema) .setOutput(ModelUtil.createPredictedOutput(FieldName.create("decisionFunction"), OpType.CONTINUOUS, DataType.DOUBLE, outlier)); Output output = supportVectorMachineModel.getOutput(); List<OutputField> outputFields = output.getOutputFields(); if(outputFields.size() != 2){ throw new IllegalArgumentException(); } OutputField decisionFunctionOutputField = outputFields.get(0); if(!decisionFunctionOutputField.isFinalResult()){ decisionFunctionOutputField.setFinalResult(true); } return supportVectorMachineModel; }
Example #5
Source File: MiningModelUtil.java From pyramid with Apache License 2.0 | 5 votes |
@Override public Feature apply(Model model){ Output output = model.getOutput(); if(output == null || !output.hasOutputFields()){ throw new IllegalArgumentException(); } OutputField outputField = Iterables.getLast(output.getOutputFields()); return new ContinuousFeature(null, outputField.getName(), outputField.getDataType()); }
Example #6
Source File: FieldResolver.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public VisitorAction visit(Output output){ if(output.hasOutputFields()){ declareFields(output, output.getOutputFields()); suppressFields(output); } return super.visit(output); }
Example #7
Source File: FieldResolver.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 5 votes |
static private List<Output> getEarlierOutputs(Segmentation segmentation, Segment targetSegment){ List<Output> result = new ArrayList<>(); Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod(); switch(multipleModelMethod){ case MODEL_CHAIN: break; default: return Collections.emptyList(); } List<Segment> segments = segmentation.getSegments(); for(Segment segment : segments){ Model model = segment.getModel(); if(targetSegment != null && (targetSegment).equals(segment)){ break; } Output output = model.getOutput(); if(output != null){ result.add(output); } } return result; }
Example #8
Source File: ModelConverter.java From jpmml-sparkml with GNU Affero General Public License v3.0 | 4 votes |
public org.dmg.pmml.Model registerModel(SparkMLEncoder encoder){ Schema schema = encodeSchema(encoder); Label label = schema.getLabel(); org.dmg.pmml.Model model = encodeModel(schema); List<OutputField> sparkOutputFields = registerOutputFields(label, model, encoder); if(sparkOutputFields != null && sparkOutputFields.size() > 0){ org.dmg.pmml.Model finalModel = MiningModelUtil.getFinalModel(model); Output output = ModelUtil.ensureOutput(finalModel); List<OutputField> outputFields = output.getOutputFields(); outputFields.addAll(sparkOutputFields); } return model; }
Example #9
Source File: JavaModel.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 4 votes |
@Override public Output getOutput(){ return this.output; }
Example #10
Source File: JavaModel.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 4 votes |
@Override public JavaModel setOutput(@Property("output") Output output){ this.output = output; return this; }
Example #11
Source File: ModelManager.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 4 votes |
protected ModelManager(PMML pmml, M model){ setPMML(Objects.requireNonNull(pmml)); setModel(Objects.requireNonNull(model)); DataDictionary dataDictionary = pmml.getDataDictionary(); if(dataDictionary == null){ throw new MissingElementException(pmml, PMMLElements.PMML_DATADICTIONARY); } // End if if(dataDictionary.hasDataFields()){ this.dataFields = CacheUtil.getValue(dataDictionary, ModelManager.dataFieldCache); } TransformationDictionary transformationDictionary = pmml.getTransformationDictionary(); if(transformationDictionary != null && transformationDictionary.hasDerivedFields()){ this.derivedFields = CacheUtil.getValue(transformationDictionary, ModelManager.derivedFieldCache); } // End if if(transformationDictionary != null && transformationDictionary.hasDefineFunctions()){ this.defineFunctions = CacheUtil.getValue(transformationDictionary, ModelManager.defineFunctionCache); } MiningFunction miningFunction = model.getMiningFunction(); if(miningFunction == null){ throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement(model.getClass()) + "@miningFunction"), model); } MiningSchema miningSchema = model.getMiningSchema(); if(miningSchema == null){ throw new MissingElementException(MissingElementException.formatMessage(XPathUtil.formatElement(model.getClass()) + "/" + XPathUtil.formatElement(MiningSchema.class)), model); } // End if if(miningSchema.hasMiningFields()){ List<MiningField> miningFields = miningSchema.getMiningFields(); for(MiningField miningField : miningFields){ FieldName name = miningField.getName(); if(name == null){ throw new MissingAttributeException(miningField, PMMLAttributes.MININGFIELD_NAME); } } this.miningFields = CacheUtil.getValue(miningSchema, ModelManager.miningFieldCache); } LocalTransformations localTransformations = model.getLocalTransformations(); if(localTransformations != null && localTransformations.hasDerivedFields()){ this.localDerivedFields = CacheUtil.getValue(localTransformations, ModelManager.localDerivedFieldCache); } Targets targets = model.getTargets(); if(targets != null && targets.hasTargets()){ this.targets = CacheUtil.getValue(targets, ModelManager.targetCache); } Output output = model.getOutput(); if(output != null && output.hasOutputFields()){ this.outputFields = CacheUtil.getValue(output, ModelManager.outputFieldCache); this.resultFeatures = CacheUtil.getValue(output, ModelManager.resultFeaturesCache); } }
Example #12
Source File: ModelManager.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 4 votes |
protected List<OutputField> createOutputFields(){ M model = getModel(); Output output = model.getOutput(); List<OutputField> outputFields = new ArrayList<>(); if(output != null && output.hasOutputFields()){ List<org.dmg.pmml.OutputField> pmmlOutputFields = output.getOutputFields(); for(org.dmg.pmml.OutputField pmmlOutputField : pmmlOutputFields){ OutputField outputField = new OutputField(pmmlOutputField); outputFields.add(outputField); } } return ImmutableList.copyOf(outputFields); }
Example #13
Source File: ModelManager.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 4 votes |
@Override public Map<FieldName, org.dmg.pmml.OutputField> load(Output output){ return IndexableUtil.buildMap(output.getOutputFields()); }
Example #14
Source File: MiningModelEvaluator.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 4 votes |
public MiningModelEvaluator(PMML pmml, MiningModel miningModel){ super(pmml, miningModel); if(miningModel.hasEmbeddedModels()){ List<EmbeddedModel> embeddedModels = miningModel.getEmbeddedModels(); EmbeddedModel embeddedModel = Iterables.getFirst(embeddedModels, null); throw new UnsupportedElementException(embeddedModel); } Segmentation segmentation = miningModel.getSegmentation(); if(segmentation == null){ throw new MissingElementException(miningModel, PMMLElements.MININGMODEL_SEGMENTATION); } Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod(); if(multipleModelMethod == null){ throw new MissingAttributeException(segmentation, PMMLAttributes.SEGMENTATION_MULTIPLEMODELMETHOD); } // End if if(!segmentation.hasSegments()){ throw new MissingElementException(segmentation, PMMLElements.SEGMENTATION_SEGMENTS); } List<Segment> segments = segmentation.getSegments(); for(Segment segment : segments){ VariableWeight variableWeight = segment.getVariableWeight(); if(variableWeight != null){ throw new UnsupportedElementException(variableWeight); } } LocalTransformations localTransformations = segmentation.getLocalTransformations(); if(localTransformations != null){ throw new UnsupportedElementException(localTransformations); } Output output = miningModel.getOutput(); if(output != null && output.hasOutputFields()){ this.segmentResultFeatures = CacheUtil.getValue(output, MiningModelEvaluator.segmentResultFeaturesCache); } }
Example #15
Source File: VersionInspectorTest.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 3 votes |
@Test public void inspectFieldAnnotations(){ PMML pmml = createPMML(); AssociationModel model = new AssociationModel(); pmml.addModels(model); assertVersionRange(pmml, Version.PMML_3_0, Version.PMML_4_4); Output output = new Output(); model.setOutput(output); assertVersionRange(pmml, Version.PMML_4_0, Version.PMML_4_4); model.setScorable(Boolean.FALSE); assertVersionRange(pmml, Version.PMML_4_1, Version.PMML_4_4); model.setScorable(null); assertVersionRange(pmml, Version.PMML_4_0, Version.PMML_4_4); OutputField outputField = new OutputField() .setRuleFeature(OutputField.RuleFeature.AFFINITY); output.addOutputFields(outputField); assertVersionRange(pmml, Version.PMML_4_1, Version.PMML_4_2); outputField.setDataType(DataType.DOUBLE); assertVersionRange(pmml, Version.PMML_4_1, Version.PMML_4_4); model.setOutput(null); assertVersionRange(pmml, Version.PMML_3_0, Version.PMML_4_4); }