public class TimeSeriesTreeLearningAlgorithm extends ASimplifiedTSCLearningAlgorithm<java.lang.Integer,TimeSeriesTreeClassifier>
| Modifier and Type | Class and Description |
|---|---|
static interface |
TimeSeriesTreeLearningAlgorithm.ITimeSeriesTreeConfig |
| Modifier and Type | Field and Description |
|---|---|
static double |
ENTROPY_APLHA
Alpha parameter used to weight the importance of the feature's margins to the
threshold candidates.
|
static int |
NUM_THRESH_CANDIDATES
Number of threshold candidates created in each tree recursion step.
|
static boolean |
USE_BIAS_CORRECTION
Indicator that the bias (Bessel's) correction should be used for the
calculation of the standard deviation.
|
| Constructor and Description |
|---|
TimeSeriesTreeLearningAlgorithm(TimeSeriesTreeLearningAlgorithm.ITimeSeriesTreeConfig config,
TimeSeriesTreeClassifier tree,
TimeSeriesDataset data)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static double |
calculateDeltaEntropy(double[] dataValues,
int[] targets,
double thresholdCandidate,
java.util.List<java.lang.Integer> classes,
double parentEntropy)
Function calculating the delta entropy for a given
thresholdCandidate and parentEntropy. |
static double |
calculateEntrance(double deltaEntropy,
double margin)
Calculates the entrance gain specified by Deng et. al. in the paper's chapter
4.1.
|
static double |
calculateMargin(double[] dataValues,
double thresholdCandidate)
Function calculating the margin between the given
thresholdCandidate and the nearest feature value from the given
dataValues. |
TimeSeriesTreeClassifier |
call()
Training procedure construction a time series tree using the given input
data.
|
void |
cancel() |
static java.util.List<java.util.List<java.lang.Double>> |
generateThresholdCandidates(ai.libs.jaicore.basic.sets.Pair<java.util.List<java.lang.Integer>,java.util.List<java.lang.Integer>> pairOfIntervalLists,
int numOfCandidates,
double[][][] transformedFeatures)
Function generating threshold candidates for each feature type.
|
int |
getBestSplitIndex(double[] deltaEntropyStarPerFeatureType)
Function returning feature type used for the split based on given the
deltaEntropy star values.
|
static ai.libs.jaicore.basic.sets.Pair<java.util.List<java.lang.Integer>,java.util.List<java.lang.Integer>> |
getChildDataIndices(double[][][] transformedData,
int n,
int fType,
int t1t2,
double threshold)
Function returning the data indices assigned to the left and the right child
of a binary tree based on the splitting criterion given by the feature type
fType, the intervals index t1t2 in the transformed
data set transformedData and the threshold. |
int |
getNumCPUs() |
ai.libs.jaicore.basic.TimeOut |
getTimeout() |
boolean |
hasNext() |
java.util.Iterator<ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent> |
iterator() |
ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent |
next() |
ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent |
nextWithException() |
static java.util.List<java.lang.Integer> |
randomlySampleNoReplacement(java.util.List<java.lang.Integer> list,
int sampleSize,
int seed)
Function sampling a given
list randomly without replacement
using the given seed. |
void |
registerListener(java.lang.Object listener) |
static ai.libs.jaicore.basic.sets.Pair<java.util.List<java.lang.Integer>,java.util.List<java.lang.Integer>> |
sampleIntervals(int m,
int seed)
Function sampling intervals based on the length of the time series
m and the given seed. |
void |
setNumCPUs(int numberOfCPUs) |
void |
setTimeout(long timeout,
java.util.concurrent.TimeUnit timeUnit) |
void |
setTimeout(ai.libs.jaicore.basic.TimeOut timeout) |
double[][][] |
transformInstances(double[][] dataset,
ai.libs.jaicore.basic.sets.Pair<java.util.List<java.lang.Integer>,java.util.List<java.lang.Integer>> pairOfItervalLists)
Method transforming the given
dataset using the interval pairs
specified in T1T2 by calculating each TimeSeriesFeature.FeatureType for
every instance and interval pair. |
void |
tree(double[][] data,
int[] targets,
double parentEntropy,
ai.libs.jaicore.graph.TreeNode<ai.libs.jaicore.ml.tsc.classifier.trees.TimeSeriesTreeClassifier.TimeSeriesTreeNodeDecisionFunction> nodeToBeFilled,
int depth)
Tree generation (cf.
|
getClassifieractivate, announceTimeoutDetected, avoidReinterruptionOnShutdownOnCurrentThread, checkAndConductTermination, checkTermination, computeTimeoutAware, getActivationTime, getConfig, getId, getInput, getLoggerName, getRemainingTimeToDeadline, getState, getTimeoutPrecautionOffset, hasThreadBeenInterruptedDuringShutdown, interruptThreadAsPartOfShutdown, isCanceled, isShutdownInitialized, isStopCriterionSatisfied, isTimeouted, post, registerActiveThread, resolveShutdownInterruptOnCurrentThread, setConfig, setLoggerName, setMaxNumThreads, setState, setTimeoutPrecautionOffset, shutdown, terminate, unregisterActiveThread, unregisterThreadAndShutdownpublic static final int NUM_THRESH_CANDIDATES
public static final double ENTROPY_APLHA
public static final boolean USE_BIAS_CORRECTION
public TimeSeriesTreeLearningAlgorithm(TimeSeriesTreeLearningAlgorithm.ITimeSeriesTreeConfig config, TimeSeriesTreeClassifier tree, TimeSeriesDataset data)
maxDepth - Maximal depth of the tree to be trainedseed - Seed used for randomized operationsuseFeatureCaching - Indicator whether feature caching should be used. Since feature
generation is very efficient, this should be only used if the time
series is very longpublic void registerListener(java.lang.Object listener)
registerListener in interface ai.libs.jaicore.basic.algorithm.IAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>registerListener in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public int getNumCPUs()
getNumCPUs in interface ai.libs.jaicore.basic.algorithm.IAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>getNumCPUs in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public void setNumCPUs(int numberOfCPUs)
setNumCPUs in interface ai.libs.jaicore.basic.algorithm.IAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>setNumCPUs in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public void setTimeout(long timeout,
java.util.concurrent.TimeUnit timeUnit)
setTimeout in interface ai.libs.jaicore.basic.algorithm.IAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>setTimeout in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public void setTimeout(ai.libs.jaicore.basic.TimeOut timeout)
setTimeout in interface ai.libs.jaicore.basic.algorithm.IAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>setTimeout in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public ai.libs.jaicore.basic.TimeOut getTimeout()
getTimeout in interface ai.libs.jaicore.basic.algorithm.IAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>getTimeout in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent nextWithException()
public TimeSeriesTreeClassifier call()
public java.util.Iterator<ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent> iterator()
iterator in interface java.lang.Iterable<ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent>iterator in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public boolean hasNext()
hasNext in interface java.util.Iterator<ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent>hasNext in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent next()
next in interface java.util.Iterator<ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent>next in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public void cancel()
cancel in interface ai.libs.jaicore.basic.Cancelablecancel in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,TimeSeriesTreeClassifier>public void tree(double[][] data,
int[] targets,
double parentEntropy,
ai.libs.jaicore.graph.TreeNode<ai.libs.jaicore.ml.tsc.classifier.trees.TimeSeriesTreeClassifier.TimeSeriesTreeNodeDecisionFunction> nodeToBeFilled,
int depth)
TimeSeriesTreeLearningAlgorithm#useFeatureCaching was set true). It then
searches for an optimal split regarding several threshold candidates for
feature splits. The splitting criterion is based on a metric called Entrance
gain which is a combination of the entropy induced by the class proportions
and the feature margins to the threshold (cf. chapter 4.1 in the paper). The
tree's recursion is stopped at a leaf node if there is no entropy gain, the
maxDepth has been reached or the local entropy is zero.data - The untransformed data which will be used for the split in the
transformed feature representationtargets - The targets of the instancesparentEntropy - The parent entropy calculated in the recursion's previous stepnodeToBeFilled - The tree node which should be filled with the splitting
information to use it for predictionsdepth - The current depth to be compared to the
TimeSeriesTreeLearningAlgorithm#maxDepthpublic static ai.libs.jaicore.basic.sets.Pair<java.util.List<java.lang.Integer>,java.util.List<java.lang.Integer>> getChildDataIndices(double[][][] transformedData,
int n,
int fType,
int t1t2,
double threshold)
fType, the intervals index t1t2 in the transformed
data set transformedData and the threshold.transformedData - Transformed data on which the split is calculatedn - The number of instancesfType - The feature type to be used for the splitt1t2 - The interval's index in the transformedData to be
used for the splitthreshold - The threshold to be used for the splitpublic int getBestSplitIndex(double[] deltaEntropyStarPerFeatureType)
deltaEntropyStarPerFeatureType - The delta entropy star value per featurepublic static double calculateDeltaEntropy(double[] dataValues,
int[] targets,
double thresholdCandidate,
java.util.List<java.lang.Integer> classes,
double parentEntropy)
thresholdCandidate and parentEntropy. The values of
the data are the feature type's values for each instance. The delta entropy
is formed of the difference between the parent entropy and the weighted sum
of the entropy values of the children and their instance assignments based on
the split.dataValues - The transformed feature type values for each instancetargets - The targets of each instancethresholdCandidate - The threshold candidate to be evaluatedclasses - List storing the classes whose indices can be looked upparentEntropy - The parent entropy used for the delta calculationpublic static double calculateEntrance(double deltaEntropy,
double margin)
deltaEntropy - The delta entropymargin - The features marginpublic static double calculateMargin(double[] dataValues,
double thresholdCandidate)
thresholdCandidate and the nearest feature value from the given
dataValues.dataValues - The feature values compared to the candidatethresholdCandidate - The threshold candidate which is assessedpublic double[][][] transformInstances(double[][] dataset,
ai.libs.jaicore.basic.sets.Pair<java.util.List<java.lang.Integer>,java.util.List<java.lang.Integer>> pairOfItervalLists)
dataset using the interval pairs
specified in T1T2 by calculating each TimeSeriesFeature.FeatureType for
every instance and interval pair.dataset - The dataset which should be transformedpairOfItervalLists - The start and end interval pairs (see
sampleIntervals(int, int))public static java.util.List<java.util.List<java.lang.Double>> generateThresholdCandidates(ai.libs.jaicore.basic.sets.Pair<java.util.List<java.lang.Integer>,java.util.List<java.lang.Integer>> pairOfIntervalLists,
int numOfCandidates,
double[][][] transformedFeatures)
numberOfCandidates candidates using equal-width intervals.pairOfIntervalLists - The pair of start and end interval pairs (see
sampleIntervals(int, int))numOfCandidates - The number of candidates to be generated per feature typetransformedFeatures - The transformed data instancespublic static ai.libs.jaicore.basic.sets.Pair<java.util.List<java.lang.Integer>,java.util.List<java.lang.Integer>> sampleIntervals(int m,
int seed)
m and the given seed. Refers to algorithm 1 of the
paper. The sampled intervals are stored in a pair of lists where each index
of the first list is related to the same index in the second list. Sampling
is done without replacement.m - Number of time series attributes (steps)seed - The seed used for the randomized samplingpublic static java.util.List<java.lang.Integer> randomlySampleNoReplacement(java.util.List<java.lang.Integer> list,
int sampleSize,
int seed)
list randomly without replacement
using the given seed. sampleSize many elements are
sampled and returned.list - List to be sampled from without replacementsampleSize - Number of elements to be sampled (must be <= list.size())seed - The seed used for the randomized sampling