Class LearnPatternSimilarityClassifier


  • public class LearnPatternSimilarityClassifier
    extends ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSClassifier<java.lang.Integer>
    Class representing the Learn Pattern Similarity classifier as described in Baydogan, Mustafa & Runger, George. (2015). Time series representation and similarity based on local autopatterns. Data Mining and Knowledge Discovery. 30. 1-34. 10.1007/s10618-015-0425-y. This classifier currently only supports univariate time series prediction.
    • Constructor Detail

      • LearnPatternSimilarityClassifier

        public LearnPatternSimilarityClassifier​(int seed,
                                                int numTrees,
                                                int maxTreeDepth,
                                                int numSegments)
        Standard constructor.
        Parameters:
        seed - Seed used for randomized operations
        numTrees - Number of trees being trained
        maxTreeDepth - Maximum depth of the trained trees
        numSegments - Number of segments used per tree for feature generation
    • Method Detail

      • predict

        public java.lang.Integer predict​(double[] univInstance)
                                  throws org.api4.java.ai.ml.core.exception.PredictionException
        Predicts the class by generated segment and segment difference features based on segments and segmentsDifference. The induced instances are propagated to the forest of RandomRegressionTrees trees. The predicted leaf nodes are used within a 1NN search on the training leaf nodes to find the nearest instance and taking its class as prediction value.
        Specified by:
        predict in class ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSClassifier<java.lang.Integer>
        Parameters:
        univInstance - Univariate instance to be predicted
        Throws:
        org.api4.java.ai.ml.core.exception.PredictionException
      • findNearestInstanceIndex

        public int findNearestInstanceIndex​(int[][] leafNodeCounts)
        Performs a simple nearest neighbor search on the stored trainLeafNodes for the given leafNodeCounts using Manhattan distance.
        Parameters:
        leafNodeCounts - Leaf node counts induced during the prediction phase
        Returns:
        Returns the index of the nearest neighbor instance
      • 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
      • getSegments

        public int[][] getSegments()
        Returns:
        the segments
      • setSegments

        public void setSegments​(int[][] segments)
        Parameters:
        segments - the segments to set
      • getSegmentsDifference

        public int[][] getSegmentsDifference()
        Returns:
        the segmentsDifference
      • setSegmentsDifference

        public void setSegmentsDifference​(int[][] segmentsDifference)
        Parameters:
        segmentsDifference - the segmentsDifference to set
      • getLengthPerTree

        public int[] getLengthPerTree()
        Returns:
        the lengthPerTree
      • setLengthPerTree

        public void setLengthPerTree​(int[] lengthPerTree)
        Parameters:
        lengthPerTree - the lengthPerTree to set
      • getClassAttIndexPerTree

        public int[] getClassAttIndexPerTree()
        Returns:
        the classAttIndexPerTree
      • setClassAttIndexPerTree

        public void setClassAttIndexPerTree​(int[] classAttIndexPerTree)
        Parameters:
        classAttIndexPerTree - the classAttIndexPerTree to set
      • setTrees

        public void setTrees​(AccessibleRandomTree[] trees)
        Parameters:
        trees - the trees to set
      • getTrainLeafNodes

        public int[][][] getTrainLeafNodes()
        Returns:
        the trainLeafNodes
      • setTrainLeafNodes

        public void setTrainLeafNodes​(int[][][] trainLeafNodes)
        Parameters:
        trainLeafNodes - the trainLeafNodes to set
      • getTrainTargets

        public int[] getTrainTargets()
        Returns:
        the trainTargets
      • setTrainTargets

        public void setTrainTargets​(int[] trainTargets)
        Parameters:
        trainTargets - the trainTargets to set
      • getAttributes

        public java.util.List<weka.core.Attribute> getAttributes()
        Returns:
        the attributes
      • setAttributes

        public void setAttributes​(java.util.List<weka.core.Attribute> attributes)
        Parameters:
        attributes - the attributes to set
      • getLearningAlgorithm

        public LearnPatternSimilarityLearningAlgorithm 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>