Java Code Examples for org.dmg.pmml.Output#hasOutputFields()

The following examples show how to use org.dmg.pmml.Output#hasOutputFields() . 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: MapHolderParser.java    From jpmml-evaluator with GNU Affero General Public License v3.0 6 votes vote down vote up
@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 2
Source File: MiningModelUtil.java    From pyramid with Apache License 2.0 5 votes vote down vote up
@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 3
Source File: FieldResolver.java    From jpmml-model with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public VisitorAction visit(Output output){

	if(output.hasOutputFields()){
		declareFields(output, output.getOutputFields());

		suppressFields(output);
	}

	return super.visit(output);
}
 
Example 4
Source File: ModelManager.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
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 5
Source File: ModelManager.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
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 6
Source File: MiningModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
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);
	}
}