Class LearnPatternSimilarityLearningAlgorithm
- java.lang.Object
-
- ai.libs.jaicore.basic.algorithm.AAlgorithm<ai.libs.jaicore.ml.classification.singlelabel.timeseries.dataset.TimeSeriesDataset2,C>
-
- ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSCLearningAlgorithm<java.lang.Integer,LearnPatternSimilarityClassifier>
-
- ai.libs.jaicore.ml.weka.classification.singlelabel.timeseries.learner.trees.LearnPatternSimilarityLearningAlgorithm
-
- All Implemented Interfaces:
java.lang.Iterable<org.api4.java.algorithm.events.IAlgorithmEvent>,java.util.concurrent.Callable<LearnPatternSimilarityClassifier>,java.util.Iterator<org.api4.java.algorithm.events.IAlgorithmEvent>,org.api4.java.algorithm.IAlgorithm<ai.libs.jaicore.ml.classification.singlelabel.timeseries.dataset.TimeSeriesDataset2,LearnPatternSimilarityClassifier>,org.api4.java.common.control.ICancelable,org.api4.java.common.control.ILoggingCustomizable,org.api4.java.common.event.IEventEmitter<java.lang.Object>,org.api4.java.common.event.IRelaxedEventEmitter
public class LearnPatternSimilarityLearningAlgorithm extends ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSCLearningAlgorithm<java.lang.Integer,LearnPatternSimilarityClassifier>
Algorithm training aLearnPatternSimilarityClassifieras 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceLearnPatternSimilarityLearningAlgorithm.IPatternSimilarityConfig
-
Constructor Summary
Constructors Constructor Description LearnPatternSimilarityLearningAlgorithm(LearnPatternSimilarityLearningAlgorithm.IPatternSimilarityConfig config, LearnPatternSimilarityClassifier model, ai.libs.jaicore.ml.classification.singlelabel.timeseries.dataset.TimeSeriesDataset2 dataset)Standard constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LearnPatternSimilarityClassifiercall()Training procedure for aLearnPatternSimilarityClassifier.static voidcollectLeafCounts(int[] leafNodeCountsForInstance, weka.core.Instance instance, AccessibleRandomTree regTree)Function collecting the leaf counts for the giveninstanceas predicted byregTree.voidgenerateSegmentsAndDifferencesForTree(int[] segments, int[] segmentsDifference, int length, int timeSeriesLength, java.util.Random random)Method generating the segment start indices and the segment difference locations randomly usingrandom.static weka.core.InstancegenerateSubseriesFeatureInstance(double[] instValues, int[] segments, int[] segmentsDifference, int len)Function generating subseries feature instances based on the givensegmentsandsegmentsDifferencematrices.static weka.core.InstancesgenerateSubseriesFeaturesInstances(java.util.List<weka.core.Attribute> attributes, int length, int[] segments, int[] segmentsDifference, double[][] dataMatrix)Function generating a dataset storing the features being generated as described in the original paper.LearnPatternSimilarityLearningAlgorithm.IPatternSimilarityConfiggetConfig()AccessibleRandomTreeinitializeRegressionTree(int numInstances)Initializes a new instance ofRandomRegressionTree.-
Methods inherited from class ai.libs.jaicore.ml.classification.singlelabel.timeseries.learner.ASimplifiedTSCLearningAlgorithm
cancel, getClassifier, hasNext, iterator, next, nextWithException, registerListener
-
Methods inherited from class ai.libs.jaicore.basic.algorithm.AAlgorithm
activate, announceTimeoutDetected, avoidReinterruptionOnShutdownOnCurrentThread, checkAndConductTermination, checkTermination, computeTimeoutAware, getActivationTime, getDeadline, getId, getInput, getListeners, getLoggerName, getNumCPUs, getRemainingTimeToDeadline, getState, getTimeout, getTimeoutPrecautionOffset, hasThreadBeenInterruptedDuringShutdown, interruptThreadAsPartOfShutdown, isCanceled, isShutdownInitialized, isStopCriterionSatisfied, isTimeoutDefined, isTimeouted, post, registerActiveThread, resolveShutdownInterruptOnCurrentThread, setConfig, setDeadline, setLoggerName, setMaxNumThreads, setNumCPUs, setState, setTimeout, setTimeout, setTimeoutPrecautionOffset, shutdown, terminate, unregisterActiveThread, unregisterThreadAndShutdown
-
-
-
-
Constructor Detail
-
LearnPatternSimilarityLearningAlgorithm
public LearnPatternSimilarityLearningAlgorithm(LearnPatternSimilarityLearningAlgorithm.IPatternSimilarityConfig config, LearnPatternSimilarityClassifier model, ai.libs.jaicore.ml.classification.singlelabel.timeseries.dataset.TimeSeriesDataset2 dataset)
Standard constructor.- Parameters:
seed- SeeLearnPatternSimilarityLearningAlgorithm#seed.numTrees- SeeLearnPatternSimilarityLearningAlgorithm#numTrees.maxTreeDepth- SeeLearnPatternSimilarityLearningAlgorithm#maxTreeDepth.numSegments- SeeLearnPatternSimilarityLearningAlgorithm#numSegments.
-
-
Method Detail
-
call
public LearnPatternSimilarityClassifier call() throws org.api4.java.algorithm.exceptions.AlgorithmException, org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
Training procedure for aLearnPatternSimilarityClassifier. At first, it generates randomly subsequences (segments) and subsequence difference locations used for feature generation. The generated features are used to train a forest ofRandomRegressionTreemodels. The predicted leaf nodes are stored in the model for a 1NN search for an equally generated prediction leaf node matrix.- Throws:
org.api4.java.algorithm.exceptions.AlgorithmExceptionorg.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
-
generateSegmentsAndDifferencesForTree
public void generateSegmentsAndDifferencesForTree(int[] segments, int[] segmentsDifference, int length, int timeSeriesLength, java.util.Random random)Method generating the segment start indices and the segment difference locations randomly usingrandom. This method used thelengthto specify the interval being generated.LearnPatternSimilarityLearningAlgorithm#numSegments* 2 many indices are generated. The start indices can only be between[0, timeSeriesLength - length]and the segment differences can only between[0, timeSeriesLength - length -1](-1 due to the fact that the next index is used for the difference calculation).- Parameters:
segments- Segment start indices used for feature generationsegmentsDifference- Segment difference start indices used for feature generationlength- The length of the segmentstimeSeriesLength- The total length of the complete time seriesrandom- Generator for the random numbers
-
initializeRegressionTree
public AccessibleRandomTree initializeRegressionTree(int numInstances)
Initializes a new instance ofRandomRegressionTree.- Parameters:
numInstances- The number of instance used for latter training (used for setting the minimum number of instances per leaf)- Returns:
- Returns the initialized tree
-
collectLeafCounts
public static void collectLeafCounts(int[] leafNodeCountsForInstance, weka.core.Instance instance, AccessibleRandomTree regTree) throws org.api4.java.ai.ml.core.exception.PredictionExceptionFunction collecting the leaf counts for the giveninstanceas predicted byregTree. The result is stored at the induced leaf node index inleafNodeCountsForInstance.- Parameters:
leafNodeCountsForInstance- The vector storing the frequencies for each leaf node of the tree being the last node within the predictioninstance- The given Weka instance which is fed to theregTreeregTree- The regression tree used for prediction- Throws:
org.api4.java.ai.ml.core.exception.PredictionException- Thrown if the random regression tree could not predict anything for the giveninstance
-
generateSubseriesFeaturesInstances
public static weka.core.Instances generateSubseriesFeaturesInstances(java.util.List<weka.core.Attribute> attributes, int length, int[] segments, int[] segmentsDifference, double[][] dataMatrix)Function generating a dataset storing the features being generated as described in the original paper. ThesegmentsandsegmentsDifferenceindices are used to extract subsequences of the givendataMatrixand generating value differences, respectively.- Parameters:
attributes- The attributes used by Weka to create the datasetlength- The length considered for the feature generationsegments- Segment start indices used for feature generationsegmentsDifference- Segment difference start indices used for feature generationdataMatrix- Matrix storing the instance values used for feature generation- Returns:
- Returns Weka instances storing the generated features
-
generateSubseriesFeatureInstance
public static weka.core.Instance generateSubseriesFeatureInstance(double[] instValues, int[] segments, int[] segmentsDifference, int len)Function generating subseries feature instances based on the givensegmentsandsegmentsDifferencematrices. Thelenparameter indicates which subsequence instance is generated within this call. The values are extracted and used for calculation (for difference) frominstValues.- Parameters:
instValues- Instance values used for feature generationsegments- Segment start indices used for feature generationsegmentsDifference- Segment difference start indices used for feature generationlen- Current length (is added to the segment and segment difference locations)- Returns:
- Returns a Weka instance storing the generated features
-
getConfig
public LearnPatternSimilarityLearningAlgorithm.IPatternSimilarityConfig getConfig()
- Specified by:
getConfigin interfaceorg.api4.java.algorithm.IAlgorithm<ai.libs.jaicore.ml.classification.singlelabel.timeseries.dataset.TimeSeriesDataset2,LearnPatternSimilarityClassifier>- Overrides:
getConfigin classai.libs.jaicore.basic.algorithm.AAlgorithm<ai.libs.jaicore.ml.classification.singlelabel.timeseries.dataset.TimeSeriesDataset2,LearnPatternSimilarityClassifier>
-
-