org.dmg.pmml.NearestNeighborModel Maven / Gradle / Ivy
package org.dmg.pmml;
import java.util.ArrayList;
import java.util.Collection;
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.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import com.sun.xml.bind.Locatable;
import com.sun.xml.bind.annotation.XmlLocation;
import org.jpmml.schema.Added;
import org.jpmml.schema.Version;
import org.xml.sax.Locator;
/**
* 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_2}Extension" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_2}MiningSchema"/>
* <element ref="{http://www.dmg.org/PMML-4_2}Output" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_2}ModelStats" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_2}ModelExplanation" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_2}Targets" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_2}LocalTransformations" minOccurs="0"/>
* <element ref="{http://www.dmg.org/PMML-4_2}TrainingInstances"/>
* <element ref="{http://www.dmg.org/PMML-4_2}ComparisonMeasure"/>
* <element ref="{http://www.dmg.org/PMML-4_2}KNNInputs"/>
* <element ref="{http://www.dmg.org/PMML-4_2}ModelVerification" minOccurs="0"/>
* </sequence>
* <attribute name="modelName" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="functionName" use="required" type="{http://www.dmg.org/PMML-4_2}MINING-FUNCTION" />
* <attribute name="algorithmName" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="numberOfNeighbors" use="required" type="{http://www.dmg.org/PMML-4_2}INT-NUMBER" />
* <attribute name="continuousScoringMethod" type="{http://www.dmg.org/PMML-4_2}CONT-SCORING-METHOD" default="average" />
* <attribute name="categoricalScoringMethod" type="{http://www.dmg.org/PMML-4_2}CAT-SCORING-METHOD" default="majorityVote" />
* <attribute name="instanceIdVariable" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="threshold" type="{http://www.dmg.org/PMML-4_2}REAL-NUMBER" default="0.001" />
* <attribute name="isScorable" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
* </restriction>
* </complexContent>
* </complexType>
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"extensions",
"miningSchema",
"output",
"modelStats",
"modelExplanation",
"targets",
"localTransformations",
"trainingInstances",
"comparisonMeasure",
"knnInputs",
"modelVerification"
})
@XmlRootElement(name = "NearestNeighborModel")
@Added(Version.PMML_4_1)
public class NearestNeighborModel
extends Model
implements Locatable, HasExtensions
{
@XmlElement(name = "Extension")
protected List extensions;
@XmlElement(name = "MiningSchema", required = true)
protected MiningSchema miningSchema;
@XmlElement(name = "Output")
protected Output output;
@XmlElement(name = "ModelStats")
protected ModelStats modelStats;
@XmlElement(name = "ModelExplanation")
protected ModelExplanation modelExplanation;
@XmlElement(name = "Targets")
protected Targets targets;
@XmlElement(name = "LocalTransformations")
protected LocalTransformations localTransformations;
@XmlElement(name = "TrainingInstances", required = true)
protected TrainingInstances trainingInstances;
@XmlElement(name = "ComparisonMeasure", required = true)
protected ComparisonMeasure comparisonMeasure;
@XmlElement(name = "KNNInputs", required = true)
protected KNNInputs knnInputs;
@XmlElement(name = "ModelVerification")
protected ModelVerification modelVerification;
@XmlAttribute(name = "modelName")
protected String modelName;
@XmlAttribute(name = "functionName", required = true)
protected MiningFunctionType functionName;
@XmlAttribute(name = "algorithmName")
protected String algorithmName;
@XmlAttribute(name = "numberOfNeighbors", required = true)
protected int numberOfNeighbors;
@XmlAttribute(name = "continuousScoringMethod")
protected ContinuousScoringMethodType continuousScoringMethod;
@XmlAttribute(name = "categoricalScoringMethod")
protected CategoricalScoringMethodType categoricalScoringMethod;
@XmlAttribute(name = "instanceIdVariable")
protected String instanceIdVariable;
@XmlAttribute(name = "threshold")
protected Double threshold;
@XmlAttribute(name = "isScorable")
@Added(Version.PMML_4_1)
protected Boolean scorable;
@XmlLocation
@XmlTransient
protected Locator locator;
public NearestNeighborModel() {
super();
}
public NearestNeighborModel(final MiningSchema miningSchema, final TrainingInstances trainingInstances, final ComparisonMeasure comparisonMeasure, final KNNInputs knnInputs, final MiningFunctionType functionName, final int numberOfNeighbors) {
super();
this.miningSchema = miningSchema;
this.trainingInstances = trainingInstances;
this.comparisonMeasure = comparisonMeasure;
this.knnInputs = knnInputs;
this.functionName = functionName;
this.numberOfNeighbors = numberOfNeighbors;
}
/**
* 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 miningSchema property.
*
* @return
* possible object is
* {@link MiningSchema }
*
*/
public MiningSchema getMiningSchema() {
return miningSchema;
}
/**
* Sets the value of the miningSchema property.
*
* @param value
* allowed object is
* {@link MiningSchema }
*
*/
public void setMiningSchema(MiningSchema value) {
this.miningSchema = value;
}
/**
* 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 value
* allowed object is
* {@link Output }
*
*/
public void setOutput(Output value) {
this.output = value;
}
/**
* 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 value
* allowed object is
* {@link ModelStats }
*
*/
public void setModelStats(ModelStats value) {
this.modelStats = value;
}
/**
* Gets the value of the modelExplanation property.
*
* @return
* possible object is
* {@link ModelExplanation }
*
*/
public ModelExplanation getModelExplanation() {
return modelExplanation;
}
/**
* Sets the value of the modelExplanation property.
*
* @param value
* allowed object is
* {@link ModelExplanation }
*
*/
public void setModelExplanation(ModelExplanation value) {
this.modelExplanation = value;
}
/**
* 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 value
* allowed object is
* {@link Targets }
*
*/
public void setTargets(Targets value) {
this.targets = value;
}
/**
* 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 value
* allowed object is
* {@link LocalTransformations }
*
*/
public void setLocalTransformations(LocalTransformations value) {
this.localTransformations = value;
}
/**
* Gets the value of the trainingInstances property.
*
* @return
* possible object is
* {@link TrainingInstances }
*
*/
public TrainingInstances getTrainingInstances() {
return trainingInstances;
}
/**
* Sets the value of the trainingInstances property.
*
* @param value
* allowed object is
* {@link TrainingInstances }
*
*/
public void setTrainingInstances(TrainingInstances value) {
this.trainingInstances = value;
}
/**
* Gets the value of the comparisonMeasure property.
*
* @return
* possible object is
* {@link ComparisonMeasure }
*
*/
public ComparisonMeasure getComparisonMeasure() {
return comparisonMeasure;
}
/**
* Sets the value of the comparisonMeasure property.
*
* @param value
* allowed object is
* {@link ComparisonMeasure }
*
*/
public void setComparisonMeasure(ComparisonMeasure value) {
this.comparisonMeasure = value;
}
/**
* Gets the value of the knnInputs property.
*
* @return
* possible object is
* {@link KNNInputs }
*
*/
public KNNInputs getKNNInputs() {
return knnInputs;
}
/**
* Sets the value of the knnInputs property.
*
* @param value
* allowed object is
* {@link KNNInputs }
*
*/
public void setKNNInputs(KNNInputs value) {
this.knnInputs = value;
}
/**
* Gets the value of the modelVerification property.
*
* @return
* possible object is
* {@link ModelVerification }
*
*/
public ModelVerification getModelVerification() {
return modelVerification;
}
/**
* Sets the value of the modelVerification property.
*
* @param value
* allowed object is
* {@link ModelVerification }
*
*/
public void setModelVerification(ModelVerification value) {
this.modelVerification = value;
}
/**
* 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 value
* allowed object is
* {@link String }
*
*/
public void setModelName(String value) {
this.modelName = value;
}
/**
* Gets the value of the functionName property.
*
* @return
* possible object is
* {@link MiningFunctionType }
*
*/
public MiningFunctionType getFunctionName() {
return functionName;
}
/**
* Sets the value of the functionName property.
*
* @param value
* allowed object is
* {@link MiningFunctionType }
*
*/
public void setFunctionName(MiningFunctionType value) {
this.functionName = value;
}
/**
* 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 value
* allowed object is
* {@link String }
*
*/
public void setAlgorithmName(String value) {
this.algorithmName = value;
}
/**
* Gets the value of the numberOfNeighbors property.
*
*/
public int getNumberOfNeighbors() {
return numberOfNeighbors;
}
/**
* Sets the value of the numberOfNeighbors property.
*
*/
public void setNumberOfNeighbors(int value) {
this.numberOfNeighbors = value;
}
/**
* Gets the value of the continuousScoringMethod property.
*
* @return
* possible object is
* {@link ContinuousScoringMethodType }
*
*/
public ContinuousScoringMethodType getContinuousScoringMethod() {
if (continuousScoringMethod == null) {
return ContinuousScoringMethodType.AVERAGE;
} else {
return continuousScoringMethod;
}
}
/**
* Sets the value of the continuousScoringMethod property.
*
* @param value
* allowed object is
* {@link ContinuousScoringMethodType }
*
*/
public void setContinuousScoringMethod(ContinuousScoringMethodType value) {
this.continuousScoringMethod = value;
}
/**
* Gets the value of the categoricalScoringMethod property.
*
* @return
* possible object is
* {@link CategoricalScoringMethodType }
*
*/
public CategoricalScoringMethodType getCategoricalScoringMethod() {
if (categoricalScoringMethod == null) {
return CategoricalScoringMethodType.MAJORITY_VOTE;
} else {
return categoricalScoringMethod;
}
}
/**
* Sets the value of the categoricalScoringMethod property.
*
* @param value
* allowed object is
* {@link CategoricalScoringMethodType }
*
*/
public void setCategoricalScoringMethod(CategoricalScoringMethodType value) {
this.categoricalScoringMethod = value;
}
/**
* Gets the value of the instanceIdVariable property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getInstanceIdVariable() {
return instanceIdVariable;
}
/**
* Sets the value of the instanceIdVariable property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setInstanceIdVariable(String value) {
this.instanceIdVariable = value;
}
/**
* Gets the value of the threshold property.
*
* @return
* possible object is
* {@link Double }
*
*/
public double getThreshold() {
if (threshold == null) {
return 0.001D;
} else {
return threshold;
}
}
/**
* Sets the value of the threshold property.
*
* @param value
* allowed object is
* {@link Double }
*
*/
public void setThreshold(Double value) {
this.threshold = value;
}
/**
* Gets the value of the scorable property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public boolean isScorable() {
if (scorable == null) {
return true;
} else {
return scorable;
}
}
/**
* Sets the value of the scorable property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setScorable(Boolean value) {
this.scorable = value;
}
public NearestNeighborModel withExtensions(Extension... values) {
if (values!= null) {
for (Extension value: values) {
getExtensions().add(value);
}
}
return this;
}
public NearestNeighborModel withExtensions(Collection values) {
if (values!= null) {
getExtensions().addAll(values);
}
return this;
}
public NearestNeighborModel withMiningSchema(MiningSchema value) {
setMiningSchema(value);
return this;
}
public NearestNeighborModel withOutput(Output value) {
setOutput(value);
return this;
}
public NearestNeighborModel withModelStats(ModelStats value) {
setModelStats(value);
return this;
}
public NearestNeighborModel withModelExplanation(ModelExplanation value) {
setModelExplanation(value);
return this;
}
public NearestNeighborModel withTargets(Targets value) {
setTargets(value);
return this;
}
public NearestNeighborModel withLocalTransformations(LocalTransformations value) {
setLocalTransformations(value);
return this;
}
public NearestNeighborModel withTrainingInstances(TrainingInstances value) {
setTrainingInstances(value);
return this;
}
public NearestNeighborModel withComparisonMeasure(ComparisonMeasure value) {
setComparisonMeasure(value);
return this;
}
public NearestNeighborModel withKNNInputs(KNNInputs value) {
setKNNInputs(value);
return this;
}
public NearestNeighborModel withModelVerification(ModelVerification value) {
setModelVerification(value);
return this;
}
public NearestNeighborModel withModelName(String value) {
setModelName(value);
return this;
}
public NearestNeighborModel withFunctionName(MiningFunctionType value) {
setFunctionName(value);
return this;
}
public NearestNeighborModel withAlgorithmName(String value) {
setAlgorithmName(value);
return this;
}
public NearestNeighborModel withNumberOfNeighbors(int value) {
setNumberOfNeighbors(value);
return this;
}
public NearestNeighborModel withContinuousScoringMethod(ContinuousScoringMethodType value) {
setContinuousScoringMethod(value);
return this;
}
public NearestNeighborModel withCategoricalScoringMethod(CategoricalScoringMethodType value) {
setCategoricalScoringMethod(value);
return this;
}
public NearestNeighborModel withInstanceIdVariable(String value) {
setInstanceIdVariable(value);
return this;
}
public NearestNeighborModel withThreshold(Double value) {
setThreshold(value);
return this;
}
public NearestNeighborModel withScorable(Boolean value) {
setScorable(value);
return this;
}
public Locator sourceLocation() {
return locator;
}
public void setSourceLocation(Locator newLocator) {
locator = newLocator;
}
@Override
public VisitorAction accept(Visitor visitor) {
VisitorAction status = visitor.visit(this);
for (int i = 0; (((status == VisitorAction.CONTINUE)&&(this.extensions!= null))&&(i