
org.dmg.pmml.tree.DecisionTree Maven / Gradle / Ivy
package org.dmg.pmml.tree;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.dmg.pmml.EmbeddedModel;
import org.dmg.pmml.Extension;
import org.dmg.pmml.HasExtensions;
import org.dmg.pmml.LocalTransformations;
import org.dmg.pmml.MiningFunction;
import org.dmg.pmml.ModelStats;
import org.dmg.pmml.Output;
import org.dmg.pmml.PMMLObject;
import org.dmg.pmml.ResultField;
import org.dmg.pmml.Targets;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.jpmml.schema.Added;
import org.jpmml.schema.Deprecated;
import org.jpmml.schema.Version;
/**
* Java class for anonymous complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{http://www.dmg.org/PMML-4_3}Extension" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_3}Output" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_3}ModelStats" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_3}Targets" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_3}LocalTransformations" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_3}ResultField" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_3}Node"/>
* </sequence>
* <attribute name="modelName" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="functionName" use="required" type="{http://www.dmg.org/PMML-4_3}MINING-FUNCTION" />
* <attribute name="algorithmName" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="missingValueStrategy" default="none">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="lastPrediction"/>
* <enumeration value="nullPrediction"/>
* <enumeration value="defaultChild"/>
* <enumeration value="weightedConfidence"/>
* <enumeration value="aggregateNodes"/>
* <enumeration value="none"/>
* </restriction>
* </simpleType>
* </attribute>
* <attribute name="missingValuePenalty" type="{http://www.dmg.org/PMML-4_3}PROB-NUMBER" default="1.0" />
* <attribute name="noTrueChildStrategy" default="returnNullPrediction">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="returnNullPrediction"/>
* <enumeration value="returnLastPrediction"/>
* </restriction>
* </simpleType>
* </attribute>
* <attribute name="splitCharacteristic" default="multiSplit">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="binarySplit"/>
* <enumeration value="multiSplit"/>
* </restriction>
* </simpleType>
* </attribute>
* </restriction>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"extensions",
"output",
"modelStats",
"targets",
"localTransformations",
"resultFields",
"node"
})
@XmlRootElement(name = "DecisionTree", namespace = "http://www.dmg.org/PMML-4_3")
@Deprecated(Version.PMML_4_1)
public class DecisionTree
extends EmbeddedModel
implements HasExtensions
{
@XmlAttribute(name = "modelName")
private String modelName;
@XmlAttribute(name = "functionName", required = true)
private MiningFunction miningFunction;
@XmlAttribute(name = "algorithmName")
private String algorithmName;
@XmlAttribute(name = "missingValueStrategy")
@Added(Version.PMML_3_1)
private DecisionTree.MissingValueStrategy missingValueStrategy;
@XmlAttribute(name = "missingValuePenalty")
@Added(Version.PMML_3_1)
private Double missingValuePenalty;
@XmlAttribute(name = "noTrueChildStrategy")
@Added(Version.PMML_3_1)
private DecisionTree.NoTrueChildStrategy noTrueChildStrategy;
@XmlAttribute(name = "splitCharacteristic")
private DecisionTree.SplitCharacteristic splitCharacteristic;
@XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_3")
private List extensions;
@XmlElement(name = "Output", namespace = "http://www.dmg.org/PMML-4_3")
@Added(Version.PMML_4_0)
private Output output;
@XmlElement(name = "ModelStats", namespace = "http://www.dmg.org/PMML-4_3")
@Added(Version.PMML_4_0)
private ModelStats modelStats;
@XmlElement(name = "Targets", namespace = "http://www.dmg.org/PMML-4_3")
@Added(Version.PMML_4_0)
private Targets targets;
@XmlElement(name = "LocalTransformations", namespace = "http://www.dmg.org/PMML-4_3")
private LocalTransformations localTransformations;
@XmlElement(name = "ResultField", namespace = "http://www.dmg.org/PMML-4_3")
private List resultFields;
@XmlElement(name = "Node", namespace = "http://www.dmg.org/PMML-4_3", required = true)
private Node node;
private final static Double DEFAULT_MISSING_VALUE_PENALTY = 1.0D;
public DecisionTree() {
super();
}
public DecisionTree(final MiningFunction miningFunction, final Node node) {
super();
this.miningFunction = miningFunction;
this.node = node;
}
/**
* Gets the value of the modelName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getModelName() {
return modelName;
}
/**
* Sets the value of the modelName property.
*
* @param modelName
* allowed object is
* {@link String }
*
*/
public DecisionTree setModelName(String modelName) {
this.modelName = modelName;
return this;
}
/**
* Gets the value of the miningFunction property.
*
* @return
* possible object is
* {@link MiningFunction }
*
*/
public MiningFunction getMiningFunction() {
return miningFunction;
}
/**
* Sets the value of the miningFunction property.
*
* @param miningFunction
* allowed object is
* {@link MiningFunction }
*
*/
public DecisionTree setMiningFunction(MiningFunction miningFunction) {
this.miningFunction = miningFunction;
return this;
}
/**
* Gets the value of the algorithmName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAlgorithmName() {
return algorithmName;
}
/**
* Sets the value of the algorithmName property.
*
* @param algorithmName
* allowed object is
* {@link String }
*
*/
public DecisionTree setAlgorithmName(String algorithmName) {
this.algorithmName = algorithmName;
return this;
}
/**
* Gets the value of the missingValueStrategy property.
*
* @return
* possible object is
* {@link DecisionTree.MissingValueStrategy }
*
*/
public DecisionTree.MissingValueStrategy getMissingValueStrategy() {
if (missingValueStrategy == null) {
return DecisionTree.MissingValueStrategy.NONE;
} else {
return missingValueStrategy;
}
}
/**
* Sets the value of the missingValueStrategy property.
*
* @param missingValueStrategy
* allowed object is
* {@link DecisionTree.MissingValueStrategy }
*
*/
public DecisionTree setMissingValueStrategy(DecisionTree.MissingValueStrategy missingValueStrategy) {
this.missingValueStrategy = missingValueStrategy;
return this;
}
/**
* Gets the value of the missingValuePenalty property.
*
* @return
* possible object is
* {@link Double }
*
*/
public Double getMissingValuePenalty() {
if (missingValuePenalty == null) {
return DEFAULT_MISSING_VALUE_PENALTY;
} else {
return missingValuePenalty;
}
}
/**
* Sets the value of the missingValuePenalty property.
*
* @param missingValuePenalty
* allowed object is
* {@link Double }
*
*/
public DecisionTree setMissingValuePenalty(Double missingValuePenalty) {
this.missingValuePenalty = missingValuePenalty;
return this;
}
/**
* Gets the value of the noTrueChildStrategy property.
*
* @return
* possible object is
* {@link DecisionTree.NoTrueChildStrategy }
*
*/
public DecisionTree.NoTrueChildStrategy getNoTrueChildStrategy() {
if (noTrueChildStrategy == null) {
return DecisionTree.NoTrueChildStrategy.RETURN_NULL_PREDICTION;
} else {
return noTrueChildStrategy;
}
}
/**
* Sets the value of the noTrueChildStrategy property.
*
* @param noTrueChildStrategy
* allowed object is
* {@link DecisionTree.NoTrueChildStrategy }
*
*/
public DecisionTree setNoTrueChildStrategy(DecisionTree.NoTrueChildStrategy noTrueChildStrategy) {
this.noTrueChildStrategy = noTrueChildStrategy;
return this;
}
/**
* Gets the value of the splitCharacteristic property.
*
* @return
* possible object is
* {@link DecisionTree.SplitCharacteristic }
*
*/
public DecisionTree.SplitCharacteristic getSplitCharacteristic() {
if (splitCharacteristic == null) {
return DecisionTree.SplitCharacteristic.MULTI_SPLIT;
} else {
return splitCharacteristic;
}
}
/**
* Sets the value of the splitCharacteristic property.
*
* @param splitCharacteristic
* allowed object is
* {@link DecisionTree.SplitCharacteristic }
*
*/
public DecisionTree setSplitCharacteristic(DecisionTree.SplitCharacteristic splitCharacteristic) {
this.splitCharacteristic = splitCharacteristic;
return this;
}
/**
* Gets the value of the extensions property.
*
*
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a set
method for the extensions property.
*
*
* For example, to add a new item, do as follows:
*
* getExtensions().add(newItem);
*
*
*
*
* Objects of the following type(s) are allowed in the list
* {@link Extension }
*
*
*/
public List getExtensions() {
if (extensions == null) {
extensions = new ArrayList();
}
return this.extensions;
}
/**
* Gets the value of the output property.
*
* @return
* possible object is
* {@link Output }
*
*/
public Output getOutput() {
return output;
}
/**
* Sets the value of the output property.
*
* @param output
* allowed object is
* {@link Output }
*
*/
public DecisionTree setOutput(Output output) {
this.output = output;
return this;
}
/**
* Gets the value of the modelStats property.
*
* @return
* possible object is
* {@link ModelStats }
*
*/
public ModelStats getModelStats() {
return modelStats;
}
/**
* Sets the value of the modelStats property.
*
* @param modelStats
* allowed object is
* {@link ModelStats }
*
*/
public DecisionTree setModelStats(ModelStats modelStats) {
this.modelStats = modelStats;
return this;
}
/**
* Gets the value of the targets property.
*
* @return
* possible object is
* {@link Targets }
*
*/
public Targets getTargets() {
return targets;
}
/**
* Sets the value of the targets property.
*
* @param targets
* allowed object is
* {@link Targets }
*
*/
public DecisionTree setTargets(Targets targets) {
this.targets = targets;
return this;
}
/**
* Gets the value of the localTransformations property.
*
* @return
* possible object is
* {@link LocalTransformations }
*
*/
public LocalTransformations getLocalTransformations() {
return localTransformations;
}
/**
* Sets the value of the localTransformations property.
*
* @param localTransformations
* allowed object is
* {@link LocalTransformations }
*
*/
public DecisionTree setLocalTransformations(LocalTransformations localTransformations) {
this.localTransformations = localTransformations;
return this;
}
/**
* Gets the value of the resultFields property.
*
*
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a set
method for the resultFields property.
*
*
* For example, to add a new item, do as follows:
*
* getResultFields().add(newItem);
*
*
*
*
* Objects of the following type(s) are allowed in the list
* {@link ResultField }
*
*
*/
public List getResultFields() {
if (resultFields == null) {
resultFields = new ArrayList();
}
return this.resultFields;
}
/**
* Gets the value of the node property.
*
* @return
* possible object is
* {@link Node }
*
*/
public Node getNode() {
return node;
}
/**
* Sets the value of the node property.
*
* @param node
* allowed object is
* {@link Node }
*
*/
public DecisionTree setNode(Node node) {
this.node = node;
return this;
}
public boolean hasExtensions() {
return ((this.extensions!= null)&&(this.extensions.size()> 0));
}
public DecisionTree addExtensions(Extension... extensions) {
getExtensions().addAll(Arrays.asList(extensions));
return this;
}
public boolean hasResultFields() {
return ((this.resultFields!= null)&&(this.resultFields.size()> 0));
}
public DecisionTree addResultFields(ResultField... resultFields) {
getResultFields().addAll(Arrays.asList(resultFields));
return this;
}
@Override
public VisitorAction accept(Visitor visitor) {
VisitorAction status = visitor.visit(this);
if (status == VisitorAction.CONTINUE) {
visitor.pushParent(this);
if ((status == VisitorAction.CONTINUE)&&hasExtensions()) {
status = PMMLObject.traverse(visitor, getExtensions());
}
if (status == VisitorAction.CONTINUE) {
status = PMMLObject.traverse(visitor, getOutput(), getModelStats(), getTargets(), getLocalTransformations());
}
if ((status == VisitorAction.CONTINUE)&&hasResultFields()) {
status = PMMLObject.traverse(visitor, getResultFields());
}
if (status == VisitorAction.CONTINUE) {
status = PMMLObject.traverse(visitor, getNode());
}
visitor.popParent();
}
if (status == VisitorAction.TERMINATE) {
return VisitorAction.TERMINATE;
}
return VisitorAction.CONTINUE;
}
/**
* Java class for null.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="lastPrediction"/>
* <enumeration value="nullPrediction"/>
* <enumeration value="defaultChild"/>
* <enumeration value="weightedConfidence"/>
* <enumeration value="aggregateNodes"/>
* <enumeration value="none"/>
* </restriction>
* </simpleType>
*
*
*/
@XmlType(name = "")
@XmlEnum
@Added(Version.PMML_3_1)
public enum MissingValueStrategy {
@XmlEnumValue("lastPrediction")
LAST_PREDICTION("lastPrediction"),
@XmlEnumValue("nullPrediction")
NULL_PREDICTION("nullPrediction"),
@XmlEnumValue("defaultChild")
DEFAULT_CHILD("defaultChild"),
@XmlEnumValue("weightedConfidence")
WEIGHTED_CONFIDENCE("weightedConfidence"),
@XmlEnumValue("aggregateNodes")
@Added(Version.PMML_3_2)
AGGREGATE_NODES("aggregateNodes"),
@XmlEnumValue("none")
NONE("none");
private final String value;
MissingValueStrategy(String v) {
value = v;
}
public String value() {
return value;
}
public static DecisionTree.MissingValueStrategy fromValue(String v) {
for (DecisionTree.MissingValueStrategy c: DecisionTree.MissingValueStrategy.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
/**
* Java class for null.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="returnNullPrediction"/>
* <enumeration value="returnLastPrediction"/>
* </restriction>
* </simpleType>
*
*
*/
@XmlType(name = "")
@XmlEnum
@Added(Version.PMML_3_1)
public enum NoTrueChildStrategy {
@XmlEnumValue("returnNullPrediction")
RETURN_NULL_PREDICTION("returnNullPrediction"),
@XmlEnumValue("returnLastPrediction")
RETURN_LAST_PREDICTION("returnLastPrediction");
private final String value;
NoTrueChildStrategy(String v) {
value = v;
}
public String value() {
return value;
}
public static DecisionTree.NoTrueChildStrategy fromValue(String v) {
for (DecisionTree.NoTrueChildStrategy c: DecisionTree.NoTrueChildStrategy.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
/**
* Java class for null.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="binarySplit"/>
* <enumeration value="multiSplit"/>
* </restriction>
* </simpleType>
*
*
*/
@XmlType(name = "")
@XmlEnum
public enum SplitCharacteristic {
@XmlEnumValue("binarySplit")
BINARY_SPLIT("binarySplit"),
@XmlEnumValue("multiSplit")
MULTI_SPLIT("multiSplit");
private final String value;
SplitCharacteristic(String v) {
value = v;
}
public String value() {
return value;
}
public static DecisionTree.SplitCharacteristic fromValue(String v) {
for (DecisionTree.SplitCharacteristic c: DecisionTree.SplitCharacteristic.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
}