All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dmg.pmml.time_series.TimeSeriesModel Maven / Gradle / Ivy

There is a newer version: 1.6.5
Show newest version

package org.dmg.pmml.time_series;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlEnum;
import jakarta.xml.bind.annotation.XmlEnumValue;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import org.dmg.pmml.Extension;
import org.dmg.pmml.HasExtensions;
import org.dmg.pmml.LocalTransformations;
import org.dmg.pmml.MathContext;
import org.dmg.pmml.MiningFunction;
import org.dmg.pmml.MiningSchema;
import org.dmg.pmml.Model;
import org.dmg.pmml.ModelExplanation;
import org.dmg.pmml.ModelStats;
import org.dmg.pmml.ModelVerification;
import org.dmg.pmml.Output;
import org.dmg.pmml.PMMLObject;
import org.dmg.pmml.StringValue;
import org.dmg.pmml.Visitor;
import org.dmg.pmml.VisitorAction;
import org.jpmml.model.MissingAttributeException;
import org.jpmml.model.MissingElementException;
import org.jpmml.model.annotations.ValueConstructor;

@XmlRootElement(name = "TimeSeriesModel", namespace = "http://www.dmg.org/PMML-4_4")
@XmlType(name = "", propOrder = {
    "extensions",
    "miningSchema",
    "output",
    "modelStats",
    "modelExplanation",
    "localTransformations",
    "timeSeries",
    "spectralAnalysis",
    "arima",
    "exponentialSmoothing",
    "seasonalTrendDecomposition",
    "stateSpaceModel",
    "garch",
    "modelVerification"
})
@org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_4_0))
@JsonRootName("TimeSeriesModel")
@JsonPropertyOrder({
    "modelName",
    "miningFunction",
    "algorithmName",
    "bestFit",
    "scorable",
    "mathContext",
    "extensions",
    "miningSchema",
    "output",
    "modelStats",
    "modelExplanation",
    "localTransformations",
    "timeSeries",
    "spectralAnalysis",
    "arima",
    "exponentialSmoothing",
    "seasonalTrendDecomposition",
    "stateSpaceModel",
    "garch",
    "modelVerification"
})
public class TimeSeriesModel
    extends Model
    implements HasExtensions
{

    @XmlAttribute(name = "modelName")
    @JsonProperty("modelName")
    private String modelName;
    @XmlAttribute(name = "functionName", required = true)
    @JsonProperty("functionName")
    private MiningFunction miningFunction;
    @XmlAttribute(name = "algorithmName")
    @JsonProperty("algorithmName")
    private String algorithmName;
    @XmlAttribute(name = "bestFit", required = true)
    @JsonProperty("bestFit")
    private TimeSeriesModel.Algorithm bestFit;
    @XmlAttribute(name = "isScorable")
    @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_4_1))
    @JsonProperty("isScorable")
    private Boolean scorable;
    @XmlAttribute(name = "x-mathContext")
    @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.XPMML))
    @JsonProperty("x-mathContext")
    private MathContext mathContext;
    @XmlElement(name = "Extension", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("Extension")
    private List extensions;
    @XmlElement(name = "MiningSchema", namespace = "http://www.dmg.org/PMML-4_4", required = true)
    @JsonProperty("MiningSchema")
    private MiningSchema miningSchema;
    @XmlElement(name = "Output", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("Output")
    private Output output;
    @XmlElement(name = "ModelStats", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("ModelStats")
    private ModelStats modelStats;
    @XmlElement(name = "ModelExplanation", namespace = "http://www.dmg.org/PMML-4_4")
    @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_4_1))
    @JsonProperty("ModelExplanation")
    private ModelExplanation modelExplanation;
    @XmlElement(name = "LocalTransformations", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("LocalTransformations")
    private LocalTransformations localTransformations;
    @XmlElement(name = "TimeSeries", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("TimeSeries")
    private List timeSeries;
    @XmlElement(name = "SpectralAnalysis", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("SpectralAnalysis")
    private SpectralAnalysis spectralAnalysis;
    @XmlElement(name = "ARIMA", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("ARIMA")
    private org.dmg.pmml.time_series.ARIMA arima;
    @XmlElement(name = "ExponentialSmoothing", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("ExponentialSmoothing")
    private ExponentialSmoothing exponentialSmoothing;
    @XmlElement(name = "SeasonalTrendDecomposition", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("SeasonalTrendDecomposition")
    private SeasonalTrendDecomposition seasonalTrendDecomposition;
    @XmlElement(name = "StateSpaceModel", namespace = "http://www.dmg.org/PMML-4_4")
    @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_4_4))
    @JsonProperty("StateSpaceModel")
    private StateSpaceModel stateSpaceModel;
    @XmlElement(name = "GARCH", namespace = "http://www.dmg.org/PMML-4_4")
    @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_4_4))
    @JsonProperty("GARCH")
    private org.dmg.pmml.time_series.GARCH garch;
    @XmlElement(name = "ModelVerification", namespace = "http://www.dmg.org/PMML-4_4")
    @JsonProperty("ModelVerification")
    private ModelVerification modelVerification;
    private final static Boolean DEFAULT_SCORABLE = true;
    private final static long serialVersionUID = 67371270L;

    public TimeSeriesModel() {
    }

    @ValueConstructor
    public TimeSeriesModel(
        @org.jpmml.model.annotations.Property("miningFunction")
        MiningFunction miningFunction,
        @org.jpmml.model.annotations.Property("bestFit")
        TimeSeriesModel.Algorithm bestFit,
        @org.jpmml.model.annotations.Property("miningSchema")
        MiningSchema miningSchema) {
        this.miningFunction = miningFunction;
        this.bestFit = bestFit;
        this.miningSchema = miningSchema;
    }

    @Override
    public String getModelName() {
        return modelName;
    }

    @Override
    public TimeSeriesModel setModelName(
        @org.jpmml.model.annotations.Property("modelName")
        String modelName) {
        this.modelName = modelName;
        return this;
    }

    @Override
    public MiningFunction requireMiningFunction() {
        if (this.miningFunction == null) {
            throw new MissingAttributeException(this, PMMLAttributes.TIMESERIESMODEL_MININGFUNCTION);
        }
        return this.miningFunction;
    }

    @Override
    public MiningFunction getMiningFunction() {
        return miningFunction;
    }

    @Override
    public TimeSeriesModel setMiningFunction(
        @org.jpmml.model.annotations.Property("miningFunction")
        MiningFunction miningFunction) {
        this.miningFunction = miningFunction;
        return this;
    }

    @Override
    public String getAlgorithmName() {
        return algorithmName;
    }

    @Override
    public TimeSeriesModel setAlgorithmName(
        @org.jpmml.model.annotations.Property("algorithmName")
        String algorithmName) {
        this.algorithmName = algorithmName;
        return this;
    }

    public TimeSeriesModel.Algorithm requireBestFit() {
        if (this.bestFit == null) {
            throw new MissingAttributeException(this, PMMLAttributes.TIMESERIESMODEL_BESTFIT);
        }
        return this.bestFit;
    }

    public TimeSeriesModel.Algorithm getBestFit() {
        return bestFit;
    }

    public TimeSeriesModel setBestFit(
        @org.jpmml.model.annotations.Property("bestFit")
        TimeSeriesModel.Algorithm bestFit) {
        this.bestFit = bestFit;
        return this;
    }

    @Override
    public boolean isScorable() {
        if (scorable == null) {
            return DEFAULT_SCORABLE;
        } else {
            return scorable;
        }
    }

    @Override
    public TimeSeriesModel setScorable(
        @org.jpmml.model.annotations.Property("scorable")
        Boolean scorable) {
        this.scorable = scorable;
        return this;
    }

    @Override
    public MathContext getMathContext() {
        if (mathContext == null) {
            return MathContext.DOUBLE;
        } else {
            return mathContext;
        }
    }

    @Override
    public TimeSeriesModel setMathContext(
        @org.jpmml.model.annotations.Property("mathContext")
        MathContext mathContext) {
        this.mathContext = mathContext;
        return this;
    }

    @Override
    public boolean hasExtensions() {
        return ((this.extensions!= null)&&(!this.extensions.isEmpty()));
    }

    @Override
    public List getExtensions() {
        if (extensions == null) {
            extensions = new ArrayList();
        }
        return this.extensions;
    }

    @Override
    public TimeSeriesModel addExtensions(Extension... extensions) {
        getExtensions().addAll(Arrays.asList(extensions));
        return this;
    }

    @Override
    public MiningSchema requireMiningSchema() {
        if (this.miningSchema == null) {
            throw new MissingElementException(this, PMMLElements.TIMESERIESMODEL_MININGSCHEMA);
        }
        return this.miningSchema;
    }

    @Override
    public MiningSchema getMiningSchema() {
        return miningSchema;
    }

    @Override
    public TimeSeriesModel setMiningSchema(
        @org.jpmml.model.annotations.Property("miningSchema")
        MiningSchema miningSchema) {
        this.miningSchema = miningSchema;
        return this;
    }

    @Override
    public Output getOutput() {
        return output;
    }

    @Override
    public TimeSeriesModel setOutput(
        @org.jpmml.model.annotations.Property("output")
        Output output) {
        this.output = output;
        return this;
    }

    @Override
    public ModelStats getModelStats() {
        return modelStats;
    }

    @Override
    public TimeSeriesModel setModelStats(
        @org.jpmml.model.annotations.Property("modelStats")
        ModelStats modelStats) {
        this.modelStats = modelStats;
        return this;
    }

    @Override
    public ModelExplanation getModelExplanation() {
        return modelExplanation;
    }

    @Override
    public TimeSeriesModel setModelExplanation(
        @org.jpmml.model.annotations.Property("modelExplanation")
        ModelExplanation modelExplanation) {
        this.modelExplanation = modelExplanation;
        return this;
    }

    @Override
    public LocalTransformations getLocalTransformations() {
        return localTransformations;
    }

    @Override
    public TimeSeriesModel setLocalTransformations(
        @org.jpmml.model.annotations.Property("localTransformations")
        LocalTransformations localTransformations) {
        this.localTransformations = localTransformations;
        return this;
    }

    public boolean hasTimeSeries() {
        return ((this.timeSeries!= null)&&(!this.timeSeries.isEmpty()));
    }

    public List getTimeSeries() {
        if (timeSeries == null) {
            timeSeries = new ArrayList();
        }
        return this.timeSeries;
    }

    public TimeSeriesModel addTimeSeries(TimeSeries... timeSeries) {
        getTimeSeries().addAll(Arrays.asList(timeSeries));
        return this;
    }

    public SpectralAnalysis getSpectralAnalysis() {
        return spectralAnalysis;
    }

    public TimeSeriesModel setSpectralAnalysis(
        @org.jpmml.model.annotations.Property("spectralAnalysis")
        SpectralAnalysis spectralAnalysis) {
        this.spectralAnalysis = spectralAnalysis;
        return this;
    }

    public org.dmg.pmml.time_series.ARIMA getARIMA() {
        return arima;
    }

    public TimeSeriesModel setARIMA(
        @org.jpmml.model.annotations.Property("arima")
        org.dmg.pmml.time_series.ARIMA arima) {
        this.arima = arima;
        return this;
    }

    public ExponentialSmoothing getExponentialSmoothing() {
        return exponentialSmoothing;
    }

    public TimeSeriesModel setExponentialSmoothing(
        @org.jpmml.model.annotations.Property("exponentialSmoothing")
        ExponentialSmoothing exponentialSmoothing) {
        this.exponentialSmoothing = exponentialSmoothing;
        return this;
    }

    public SeasonalTrendDecomposition getSeasonalTrendDecomposition() {
        return seasonalTrendDecomposition;
    }

    public TimeSeriesModel setSeasonalTrendDecomposition(
        @org.jpmml.model.annotations.Property("seasonalTrendDecomposition")
        SeasonalTrendDecomposition seasonalTrendDecomposition) {
        this.seasonalTrendDecomposition = seasonalTrendDecomposition;
        return this;
    }

    public StateSpaceModel getStateSpaceModel() {
        return stateSpaceModel;
    }

    public TimeSeriesModel setStateSpaceModel(
        @org.jpmml.model.annotations.Property("stateSpaceModel")
        StateSpaceModel stateSpaceModel) {
        this.stateSpaceModel = stateSpaceModel;
        return this;
    }

    public org.dmg.pmml.time_series.GARCH getGARCH() {
        return garch;
    }

    public TimeSeriesModel setGARCH(
        @org.jpmml.model.annotations.Property("garch")
        org.dmg.pmml.time_series.GARCH garch) {
        this.garch = garch;
        return this;
    }

    @Override
    public ModelVerification getModelVerification() {
        return modelVerification;
    }

    @Override
    public TimeSeriesModel setModelVerification(
        @org.jpmml.model.annotations.Property("modelVerification")
        ModelVerification modelVerification) {
        this.modelVerification = modelVerification;
        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, getMiningSchema(), getOutput(), getModelStats(), getModelExplanation(), getLocalTransformations());
            }
            if ((status == VisitorAction.CONTINUE)&&hasTimeSeries()) {
                status = PMMLObject.traverse(visitor, getTimeSeries());
            }
            if (status == VisitorAction.CONTINUE) {
                status = PMMLObject.traverse(visitor, getSpectralAnalysis(), getARIMA(), getExponentialSmoothing(), getSeasonalTrendDecomposition(), getStateSpaceModel(), getGARCH(), getModelVerification());
            }
            visitor.popParent();
        }
        if (status == VisitorAction.TERMINATE) {
            return VisitorAction.TERMINATE;
        }
        return VisitorAction.CONTINUE;
    }

    @XmlType(name = "")
    @XmlEnum
    public enum Algorithm
        implements StringValue
    {

        @JsonProperty("ARIMA")
        ARIMA("ARIMA"),
        @XmlEnumValue("ExponentialSmoothing")
        @JsonProperty("ExponentialSmoothing")
        EXPONENTIAL_SMOOTHING("ExponentialSmoothing"),
        @XmlEnumValue("SeasonalTrendDecomposition")
        @JsonProperty("SeasonalTrendDecomposition")
        SEASONAL_TREND_DECOMPOSITION("SeasonalTrendDecomposition"),
        @XmlEnumValue("SpectralAnalysis")
        @JsonProperty("SpectralAnalysis")
        SPECTRAL_ANALYSIS("SpectralAnalysis"),
        @XmlEnumValue("StateSpaceModel")
        @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_4_4))
        @JsonProperty("StateSpaceModel")
        STATE_SPACE_MODEL("StateSpaceModel"),
        @org.jpmml.model.annotations.Added((org.dmg.pmml.Version.PMML_4_4))
        @JsonProperty("GARCH")
        GARCH("GARCH");
        private final String value;

        Algorithm(String v) {
            value = v;
        }

        @Override
        public String value() {
            return value;
        }

        public static TimeSeriesModel.Algorithm fromValue(String v) {
            for (TimeSeriesModel.Algorithm c: TimeSeriesModel.Algorithm.values()) {
                if (c.value.equals(v)) {
                    return c;
                }
            }
            throw new IllegalArgumentException(v);
        }

        @Override
        public String toString() {
            return value();
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy