public class LearnShapeletsLearningAlgorithm extends ASimplifiedTSCLearningAlgorithm<java.lang.Integer,LearnShapeletsClassifier>
LearnShapeletsClassifier published in "J. Grabocka, N.
Schilling, M. Wistuba, L. Schmidt-Thieme: Learning Time-Series Shapelets"
(https://www.ismll.uni-hildesheim.de/pub/pdfs/grabocka2014e-kdd.pdf)| Modifier and Type | Class and Description |
|---|---|
static interface |
LearnShapeletsLearningAlgorithm.ILearnShapeletsLearningAlgorithmConfig |
| Modifier and Type | Field and Description |
|---|---|
static double |
ALPHA
Predefined alpha parameter used within the calculations.
|
static boolean |
USE_BIAS_CORRECTION
Indicator whether Bessel's correction should be used when normalizing arrays.
|
| Constructor and Description |
|---|
LearnShapeletsLearningAlgorithm(LearnShapeletsLearningAlgorithm.ILearnShapeletsLearningAlgorithmConfig config,
LearnShapeletsClassifier classifier,
TimeSeriesDataset dataset)
Constructor of the algorithm to train a
LearnShapeletsClassifier. |
| Modifier and Type | Method and Description |
|---|---|
static double |
calculateD(double[][][] s,
int minShapeLength,
int r,
double[] instance,
int k,
int j)
Function to calculate the distance between the
j-th segment of
the given time series instance and the k-th
shapelet stored in the shapelet tensor S. |
static double |
calculateMHat(double[][][] s,
int minShapeLength,
int r,
double[] instance,
int k,
int Q,
double alpha)
Function to calculate the soft-minimum function which is a differentiable
approximation of the minimum distance matrix given in the paper in section
3.1.4.
|
LearnShapeletsClassifier |
call()
Main function to train a
LearnShapeletsClassifier. |
int |
getC() |
LearnShapeletsLearningAlgorithm.ILearnShapeletsLearningAlgorithmConfig |
getConfig() |
static int |
getNumberOfSegments(int Q,
int minShapeLength,
int r)
Returns the number of segments which are available for a instance with
Q attributes for a given scale r and a minimum
shape length minShapeLength. |
double[][][] |
initializeS(double[][] trainingMatrix)
Initializes the tensor
S storing the shapelets for each scale. |
void |
initializeWeights(double[][][] w,
double[] w0)
Randomly initializes the weights around zero.
|
boolean |
isUseInstanceReordering() |
ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent |
nextWithException() |
void |
performSGD(double[][][] w,
double[][][] wHist,
double[] w0,
double[] w0Hist,
double[][][] s,
double[][][] sHist,
double[][] dataMatrix,
int[][] y,
long beginTime,
int[] targets)
Method performing the stochastic gradient descent to learn the weights and
shapelets.
|
void |
setC(int c) |
void |
setUseInstanceReordering(boolean useInstanceReordering) |
java.util.List<java.lang.Integer> |
shuffleAccordingToAlternatingClassScheme(java.util.List<java.lang.Integer> instanceIndices,
int[] targets,
java.util.Random random)
Shuffles the data in a class alternating scheme.
|
cancel, getClassifier, hasNext, iterator, next, registerListeneractivate, announceTimeoutDetected, avoidReinterruptionOnShutdownOnCurrentThread, checkAndConductTermination, checkTermination, computeTimeoutAware, getActivationTime, getId, getInput, getLoggerName, getNumCPUs, getRemainingTimeToDeadline, getState, getTimeout, getTimeoutPrecautionOffset, hasThreadBeenInterruptedDuringShutdown, interruptThreadAsPartOfShutdown, isCanceled, isShutdownInitialized, isStopCriterionSatisfied, isTimeouted, post, registerActiveThread, resolveShutdownInterruptOnCurrentThread, setConfig, setLoggerName, setMaxNumThreads, setNumCPUs, setState, setTimeout, setTimeout, setTimeoutPrecautionOffset, shutdown, terminate, unregisterActiveThread, unregisterThreadAndShutdownpublic static final boolean USE_BIAS_CORRECTION
public static final double ALPHA
public LearnShapeletsLearningAlgorithm(LearnShapeletsLearningAlgorithm.ILearnShapeletsLearningAlgorithmConfig config, LearnShapeletsClassifier classifier, TimeSeriesDataset dataset)
LearnShapeletsClassifier.public double[][][] initializeS(double[][] trainingMatrix)
throws TrainingException
S storing the shapelets for each scale.
The initialization is done by deriving inital shapelets from all normalized
segments.trainingMatrix - The training matrix used for the initialization of S.TrainingExceptionpublic LearnShapeletsClassifier call() throws ai.libs.jaicore.basic.algorithm.exceptions.AlgorithmException
LearnShapeletsClassifier.ai.libs.jaicore.basic.algorithm.exceptions.AlgorithmExceptionpublic void initializeWeights(double[][][] w,
double[] w0)
w - The weight matrixw0 - The bias vectorpublic void performSGD(double[][][] w,
double[][][] wHist,
double[] w0,
double[] w0Hist,
double[][][] s,
double[][][] sHist,
double[][] dataMatrix,
int[][] y,
long beginTime,
int[] targets)
w - The weight matrixwHist - The weight's history matrix used for smoothing learningw0 - The bias vectorw0Hist - The bias' history vector used for smoothing learnings - The shapelet matrixsHist - The shapelet's history matrix used for smoothing learningdataMatrix - The data values matrixy - The binarized target matrixbeginTime - The begin time used to check for the timeoutpublic java.util.List<java.lang.Integer> shuffleAccordingToAlternatingClassScheme(java.util.List<java.lang.Integer> instanceIndices,
int[] targets,
java.util.Random random)
instanceIndices - The instance indices the original datasettargets - The targets of each instancerandom - Random object used for randomized shufflinginstanceIndices is only used once
(without replacement)public static double calculateMHat(double[][][] s,
int minShapeLength,
int r,
double[] instance,
int k,
int Q,
double alpha)
s - The tensor storing the shapelets for different scalesminShapeLength - The minimum shape lengthr - The number of scale to look atinstance - The instance time series vectork - The index of the shapelet to look atQ - The number of attributes (time series length)alpha - Parameter to control the desired precision of the M_hat
approximationr and
k.public static double calculateD(double[][][] s,
int minShapeLength,
int r,
double[] instance,
int k,
int j)
j-th segment of
the given time series instance and the k-th
shapelet stored in the shapelet tensor S.s - The tensor storing the shapelets for different scalesminShapeLength - The minimum shape lengthr - The number of scale to look atinstance - The instance time series vectork - The index of the shapelet to look atj - The segment of the instance time series to look atj-th segment of the
instance and the shapelet given by the parameters r,
k and j.public ai.libs.jaicore.basic.algorithm.events.AlgorithmEvent nextWithException()
nextWithException in interface ai.libs.jaicore.basic.algorithm.IAlgorithm<TimeSeriesDataset,LearnShapeletsClassifier>nextWithException in class ASimplifiedTSCLearningAlgorithm<java.lang.Integer,LearnShapeletsClassifier>public static int getNumberOfSegments(int Q,
int minShapeLength,
int r)
Q attributes for a given scale r and a minimum
shape length minShapeLength.Q - Number of attributes of an instanceminShapeLength - Minimum shapelet lengthr - Scale to be looked atQ time series attributespublic LearnShapeletsLearningAlgorithm.ILearnShapeletsLearningAlgorithmConfig getConfig()
getConfig in interface ai.libs.jaicore.basic.algorithm.IAlgorithm<TimeSeriesDataset,LearnShapeletsClassifier>getConfig in class ai.libs.jaicore.basic.algorithm.AAlgorithm<TimeSeriesDataset,LearnShapeletsClassifier>public boolean isUseInstanceReordering()
public void setUseInstanceReordering(boolean useInstanceReordering)
useInstanceReordering - the useInstanceReordering to setpublic int getC()
public void setC(int c)
c - the c to set