Class LearnPatternSimilarityClassifier
- java.lang.Object
-
- ai.libs.jaicore.ml.tsc.classifier.ASimplifiedTSClassifier<java.lang.Integer>
-
- ai.libs.jaicore.ml.tsc.classifier.trees.LearnPatternSimilarityClassifier
-
public class LearnPatternSimilarityClassifier extends 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.
-
-
Field Summary
-
Fields inherited from class ai.libs.jaicore.ml.tsc.classifier.ASimplifiedTSClassifier
classMapper, trained
-
-
Constructor Summary
Constructors Constructor Description LearnPatternSimilarityClassifier(int seed, int numTrees, int maxTreeDepth, int numSegments)Standard constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intfindNearestInstanceIndex(int[][] leafNodeCounts)Performs a simple nearest neighbor search on the storedtrainLeafNodesfor the givenleafNodeCountsusing Manhattan distance.java.util.List<weka.core.Attribute>getAttributes()int[]getClassAttIndexPerTree()LearnPatternSimilarityLearningAlgorithmgetLearningAlgorithm(TimeSeriesDataset dataset)int[]getLengthPerTree()int[][]getSegments()int[][]getSegmentsDifference()int[][][]getTrainLeafNodes()int[]getTrainTargets()AccessibleRandomTree[]getTrees()java.lang.Integerpredict(double[] univInstance)Predicts the class by generated segment and segment difference features based onsegmentsandsegmentsDifference.java.util.List<java.lang.Integer>predict(TimeSeriesDataset dataset)Performs predictions based on the given instances in the given dataset.java.lang.Integerpredict(java.util.List<double[]> multivInstance)Performs a prediction based on the given multivariate list of double[] instance representation and returns the result.voidsetAttributes(java.util.List<weka.core.Attribute> attributes)voidsetClassAttIndexPerTree(int[] classAttIndexPerTree)voidsetLengthPerTree(int[] lengthPerTree)voidsetSegments(int[][] segments)voidsetSegmentsDifference(int[][] segmentsDifference)voidsetTrainLeafNodes(int[][][] trainLeafNodes)voidsetTrainTargets(int[] trainTargets)voidsetTrees(AccessibleRandomTree[] trees)-
Methods inherited from class ai.libs.jaicore.ml.tsc.classifier.ASimplifiedTSClassifier
checkWhetherPredictionIsPossible, getClassMapper, isTrained, setClassMapper, train
-
-
-
-
Constructor Detail
-
LearnPatternSimilarityClassifier
public LearnPatternSimilarityClassifier(int seed, int numTrees, int maxTreeDepth, int numSegments)Standard constructor.- Parameters:
seed- Seed used for randomized operationsnumTrees- Number of trees being trainedmaxTreeDepth- Maximum depth of the trained treesnumSegments- Number of segments used per tree for feature generation
-
-
Method Detail
-
predict
public java.lang.Integer predict(double[] univInstance) throws PredictionExceptionPredicts the class by generated segment and segment difference features based onsegmentsandsegmentsDifference. The induced instances are propagated to the forest ofRandomRegressionTreestrees. 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:
predictin classASimplifiedTSClassifier<java.lang.Integer>- Parameters:
univInstance- Univariate instance to be predicted- Returns:
- Returns the result of the prediction
- Throws:
PredictionException- If something fails during the prediction process.
-
findNearestInstanceIndex
public int findNearestInstanceIndex(int[][] leafNodeCounts)
Performs a simple nearest neighbor search on the storedtrainLeafNodesfor the givenleafNodeCountsusing 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 PredictionExceptionPerforms a prediction based on the given multivariate list of double[] instance representation and returns the result.- Overrides:
predictin classASimplifiedTSClassifier<java.lang.Integer>- Parameters:
multivInstance- Multivariate instance given by a list of multiple double[] time series used for the prediction- Returns:
- Returns the result of the prediction
- Throws:
PredictionException- If something fails during the prediction process.
-
predict
public java.util.List<java.lang.Integer> predict(TimeSeriesDataset dataset) throws PredictionException
Performs predictions based on the given instances in the given dataset.- Specified by:
predictin classASimplifiedTSClassifier<java.lang.Integer>- Parameters:
dataset- TheTimeSeriesDatasetfor which predictions should be made.- Returns:
- Returns the result of the predictions
- Throws:
PredictionException- If something fails during the prediction process
-
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
-
getTrees
public AccessibleRandomTree[] getTrees()
- Returns:
- the trees
-
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(TimeSeriesDataset dataset)
- Specified by:
getLearningAlgorithmin classASimplifiedTSClassifier<java.lang.Integer>
-
-