Class TimeSeriesBagOfFeaturesClassifier


  • public class TimeSeriesBagOfFeaturesClassifier
    extends ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSClassifier<java.lang.Integer>
    Implementation of the Time Series Bag-of-Features (TSBF) classifier as described in Baydogan, Mustafa & Runger, George & Tuv, Eugene. (2013). A Bag-of-Features Framework to Classify Time Series. IEEE Transactions on Pattern Analysis and Machine Intelligence. 35. 2796-802. 10.1109/TPAMI.2013.72. This classifier only supports univariate time series prediction.
    • Field Summary

      • Fields inherited from class ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSClassifier

        classMapper, trained
    • Constructor Summary

      Constructors 
      Constructor Description
      TimeSeriesBagOfFeaturesClassifier​(int seed)
      Standard constructor using the default parameters (numBins = 10, numFolds = 10, zProp = 0.1, minIntervalLength = 5) for the TSBF classifier.
      TimeSeriesBagOfFeaturesClassifier​(int seed, int numBins, int numFolds, double zProp, int minIntervalLength)
      Constructor specifying parameters (cf.
      TimeSeriesBagOfFeaturesClassifier​(int seed, int numBins, int numFolds, double zProp, int minIntervalLength, boolean useZNormalization)
      Constructor specifying parameters (cf.
    • Constructor Detail

      • TimeSeriesBagOfFeaturesClassifier

        public TimeSeriesBagOfFeaturesClassifier​(int seed)
        Standard constructor using the default parameters (numBins = 10, numFolds = 10, zProp = 0.1, minIntervalLength = 5) for the TSBF classifier.
        Parameters:
        seed - Seed used for randomized operations
      • TimeSeriesBagOfFeaturesClassifier

        public TimeSeriesBagOfFeaturesClassifier​(int seed,
                                                 int numBins,
                                                 int numFolds,
                                                 double zProp,
                                                 int minIntervalLength)
        Constructor specifying parameters (cf. TimeSeriesBagOfFeaturesClassifier(int)).
        Parameters:
        seed - Seed used for randomized operations
        numBins - See TimeSeriesBagOfFeaturesClassifier#numBins
        numFolds - Number of folds for the internal OOB probability CV estimation
        zProp - Proportion of the total time series length to be used for the subseries generation
        minIntervalLength - The minimal interval length used for the interval generation
      • TimeSeriesBagOfFeaturesClassifier

        public TimeSeriesBagOfFeaturesClassifier​(int seed,
                                                 int numBins,
                                                 int numFolds,
                                                 double zProp,
                                                 int minIntervalLength,
                                                 boolean useZNormalization)
        Constructor specifying parameters (cf. TimeSeriesBagOfFeaturesClassifier(int)).
        Parameters:
        seed - Seed used for randomized operations
        numBins - See TimeSeriesBagOfFeaturesClassifier#numBins
        numFolds - Number of folds for the internal OOB probability CV estimation
        zProp - Proportion of the total time series length to be used for the subseries generation
        minIntervalLength - The minimal interval length used for the interval generation
        useZNormalization - Indicator whether the Z normalization should be used
    • Method Detail

      • predict

        public java.lang.Integer predict​(double[] univInstance)
                                  throws org.api4.java.ai.ml.core.exception.PredictionException
        Method predicting the class of the given univInstance. At first, an internal feature representation using a bag of features is generated by the previously trained subsequences and intervals. These internal instances are used to get an internal class probability estimation for each subsequence and interval for each instance using a Random Forest classifier. These probabilities are aggregated to a histogram which is then fed to a final Random Forest classifier predicting the instance's target class.
        Specified by:
        predict in class ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSClassifier<java.lang.Integer>
        Throws:
        org.api4.java.ai.ml.core.exception.PredictionException
      • predict

        public java.lang.Integer predict​(java.util.List<double[]> multivInstance)
                                  throws org.api4.java.ai.ml.core.exception.PredictionException
        Overrides:
        predict in class ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSClassifier<java.lang.Integer>
        Throws:
        org.api4.java.ai.ml.core.exception.PredictionException
      • predict

        public java.util.List<java.lang.Integer> predict​(ai.libs.jaicore.ml.classification.singlelabel.timeseries.dataset.TimeSeriesDataset2 dataset)
                                                  throws org.api4.java.ai.ml.core.exception.PredictionException
        Specified by:
        predict in class ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSClassifier<java.lang.Integer>
        Throws:
        org.api4.java.ai.ml.core.exception.PredictionException
      • getSubseriesClf

        public weka.classifiers.trees.RandomForest getSubseriesClf()
        Returns:
        the subseriesClf
      • setSubseriesClf

        public void setSubseriesClf​(weka.classifiers.trees.RandomForest subseriesClf)
        Parameters:
        subseriesClf - the subseriesClf to set
      • getFinalClf

        public weka.classifiers.trees.RandomForest getFinalClf()
        Returns:
        the finalClf
      • setFinalClf

        public void setFinalClf​(weka.classifiers.trees.RandomForest finalClf)
        Parameters:
        finalClf - the finalClf to set
      • getNumBins

        public int getNumBins()
        Returns:
        the numBins
      • setNumBins

        public void setNumBins​(int numBins)
        Parameters:
        numBins - the numBins to set
      • getNumClasses

        public int getNumClasses()
        Returns:
        the numClasses
      • setNumClasses

        public void setNumClasses​(int numClasses)
        Parameters:
        numClasses - the numClasses to set
      • getIntervals

        public int[][][] getIntervals()
        Returns:
        the intervals
      • setIntervals

        public void setIntervals​(int[][][] intervals)
        Parameters:
        intervals - the intervals to set
      • getSubsequences

        public int[][] getSubsequences()
        Returns:
        the subsequences
      • setSubsequences

        public void setSubsequences​(int[][] subsequences)
        Parameters:
        subsequences - the subsequences to set
      • getLearningAlgorithm

        public TimeSeriesBagOfFeaturesLearningAlgorithm getLearningAlgorithm​(ai.libs.jaicore.ml.classification.singlelabel.timeseries.dataset.TimeSeriesDataset2 dataset)
        Specified by:
        getLearningAlgorithm in class ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSClassifier<java.lang.Integer>