public class TimeSeriesUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static double |
EPSILON |
| Modifier and Type | Method and Description |
|---|---|
static double[] |
backwardDifferenceDerivate(double[] t)
Calclualtes f'(n) = f(n-1) - f(n)
|
static double[] |
backwardDifferenceDerivateWithBoundaries(double[] t)
Calclualtes f'(n) = f(n-1) - f(n)
|
static TimeSeriesDataset |
createDatasetForMatrix(double[][]... valueMatrices)
Function creating a
TimeSeriesDataset object given one or multiple
valueMatrices. |
static TimeSeriesDataset |
createDatasetForMatrix(int[] targets,
double[][]... valueMatrices)
|
static double[] |
createEquidistantTimestamps(double[] timeSeries)
Creates equidistant timestamps for a time series.
|
static org.nd4j.linalg.api.ndarray.INDArray |
createEquidistantTimestamps(org.nd4j.linalg.api.ndarray.INDArray timeSeries)
Creates equidistant timestamps for a time series.
|
static double[] |
forwardDifferenceDerivate(double[] t)
f'(n) = f(n+1) - f(n)
|
static double[] |
forwardDifferenceDerivateWithBoundaries(double[] t)
f'(n) = f(n+1) - f(n)
|
static java.util.List<java.lang.Integer> |
getClassesInDataset(TimeSeriesDataset dataset)
Returns a list storing the unique Integer class values in the given
dataset. |
static double[] |
getInterval(double[] timeSeries,
int start,
int end)
Function extracting the interval [start, end (exclusive)] out of the given
timeSeries vector. |
static <T> T |
getMaximumKeyByValue(java.util.Map<T,java.lang.Integer> map)
Returns the key with the maximum integer value.
|
static int |
getMode(int[] array)
Returns the mode of the given
array. |
static int |
getNumberOfClasses(TimeSeriesDataset dataset)
Counts the number of unique classes occurring in the given
dataset. |
static ai.libs.jaicore.basic.sets.Pair<TimeSeriesDataset,TimeSeriesDataset> |
getTrainingAndTestDataForFold(int fold,
int numFolds,
double[][] srcValueMatrix,
int[] srcTargetMatrix)
Functions creating two
TimeSeriesDataset objects representing the
training and test split for the given fold of a cross validation
with numFolds many folds. |
static double[] |
gulloDerivate(double[] t)
Calculates the derivative of a timeseries as described first by Gullo et. al
(2009).
|
static double[] |
gulloDerivateWithBoundaries(double[] t)
f'(n) = \frac{f(i+1)-f(i-1)}{2}
|
static boolean |
isSameLength(double[] timeSeries1,
double[]... timeSeries)
Checks whether multiple arrays have the same length.
|
static boolean |
isSameLength(org.nd4j.linalg.api.ndarray.INDArray timeSeries1,
org.nd4j.linalg.api.ndarray.INDArray... timeSeries)
Checks whether multiple arrays have the same length.
|
static void |
isSameLengthOrException(double[] timeSeries1,
double[]... timeSeries)
Checks whether multiple arrays have the same length.
|
static void |
isSameLengthOrException(org.nd4j.linalg.api.ndarray.INDArray timeSeries1,
org.nd4j.linalg.api.ndarray.INDArray... timeSeries)
Checks whether multiple arrays have the same length.
|
static boolean |
isTimeSeries(org.nd4j.linalg.api.ndarray.INDArray... array)
Checks, whether given INDArray are valid time series.
|
static boolean |
isTimeSeries(int length,
double[]... array)
Checks, whether given array are valid time series with a given length.
|
static boolean |
isTimeSeries(int length,
org.nd4j.linalg.api.ndarray.INDArray... array)
Checks, whether given INDArrays are valid time series with a given length.
|
static void |
isTimeSeriesOrException(org.nd4j.linalg.api.ndarray.INDArray... array)
Checks, whether given INDArrays are valid time series.
|
static void |
isTimeSeriesOrException(int length,
double[]... array)
Checks, whether given INDArrays are valid time series with a given length.
|
static void |
isTimeSeriesOrException(int length,
org.nd4j.linalg.api.ndarray.INDArray... array)
Checks, whether given INDArrays are valid time series with a given length.
|
static double[] |
keoghDerivate(double[] t)
Calculates the derivative of a timeseries as described first by Keogh and
Pazzani (2001).
|
static double[] |
keoghDerivateWithBoundaries(double[] t)
Calculates the derivateive of a timeseries as described first by Keogh and
Pazzani (2001).
|
static double |
mean(double[] t) |
static double[] |
normalizeByStandardDeviation(double[] t) |
static org.nd4j.linalg.api.ndarray.INDArray |
normalizeINDArray(org.nd4j.linalg.api.ndarray.INDArray array,
boolean inplace)
Normalizes an INDArray vector object.
|
static void |
shuffleTimeSeriesDataset(TimeSeriesDataset dataset,
int seed)
Shuffles the given
TimeSeriesDataset object using the given
seed. |
static java.util.List<java.lang.Integer> |
sortIndexes(double[] vector,
boolean ascending)
Sorts the indices of the given
vector based on the the vector's
values (argsort). |
static double |
standardDeviation(double[] t)
Calculates the (population) standard deviation of the values of a times
series.
|
static double |
sum(double[] t) |
static java.lang.String |
toString(double[] timeSeries)
Enables printing of time series.
|
static double |
variance(double[] t)
Calculates the (population) variance of the values of a times series.
|
static double[] |
zNormalize(double[] dataVector,
boolean besselsCorrection)
Z-normalizes a given
dataVector. |
static double[] |
zTransform(double[] t) |
public static final double EPSILON
public static boolean isTimeSeries(org.nd4j.linalg.api.ndarray.INDArray... array)
array - public static boolean isTimeSeries(int length,
org.nd4j.linalg.api.ndarray.INDArray... array)
array - length - public static boolean isTimeSeries(int length,
double[]... array)
array - length - public static void isTimeSeriesOrException(org.nd4j.linalg.api.ndarray.INDArray... array)
array - java.lang.IllegalArgumentExceptionpublic static void isTimeSeriesOrException(int length,
org.nd4j.linalg.api.ndarray.INDArray... array)
array - length - java.lang.IllegalArgumentExceptionpublic static void isTimeSeriesOrException(int length,
double[]... array)
array - length - java.lang.IllegalArgumentExceptionpublic static boolean isSameLength(org.nd4j.linalg.api.ndarray.INDArray timeSeries1,
org.nd4j.linalg.api.ndarray.INDArray... timeSeries)
timeSeries1 - timeSeries2 - public static boolean isSameLength(double[] timeSeries1,
double[]... timeSeries)
timeSeries1 - timeSeries2 - public static void isSameLengthOrException(org.nd4j.linalg.api.ndarray.INDArray timeSeries1,
org.nd4j.linalg.api.ndarray.INDArray... timeSeries)
timeSeries1 - timeSeries2 - TimeSeriesLengthExceptionpublic static void isSameLengthOrException(double[] timeSeries1,
double[]... timeSeries)
timeSeries1 - timeSeries2 - TimeSeriesLengthExceptionpublic static org.nd4j.linalg.api.ndarray.INDArray createEquidistantTimestamps(org.nd4j.linalg.api.ndarray.INDArray timeSeries)
timeSeries - Time series to generate timestamps for. Let n be its
length.public static double[] createEquidistantTimestamps(double[] timeSeries)
timeSeries - Time series to generate timestamps for. Let n be its
length.public static double[] getInterval(double[] timeSeries,
int start,
int end)
timeSeries vector.timeSeries - Time series vector sourcestart - Start of the intervalend - End index of the interval (exclusive)public static org.nd4j.linalg.api.ndarray.INDArray normalizeINDArray(org.nd4j.linalg.api.ndarray.INDArray array,
boolean inplace)
array - INDArray row vector with single shape dimensioninplace - Indication whether the normalization should be performed in
place or on a new array copypublic static int getMode(int[] array)
array. If there are multiple
values with the same frequency, the lower value will be taken.array - The array which mode should be returnedpublic static <T> T getMaximumKeyByValue(java.util.Map<T,java.lang.Integer> map)
map - The map storing the keys with its corresponding integer valuespublic static double[] zNormalize(double[] dataVector,
boolean besselsCorrection)
dataVector. Uses Bessel's correction
(1/(n-1) in the calculation of the standard deviation) if set.dataVector - Vector to be z-normalizedbesselsCorrection - Indicator whether the std dev correction using n-1
instead of n should be appliedpublic static java.util.List<java.lang.Integer> sortIndexes(double[] vector,
boolean ascending)
vector based on the the vector's
values (argsort).vector - Vector where the values are extracted fromascending - Indicator whether the indices should be sorted ascendingpublic static int getNumberOfClasses(TimeSeriesDataset dataset)
dataset.dataset - Dataset to be evaluateddatasetpublic static java.util.List<java.lang.Integer> getClassesInDataset(TimeSeriesDataset dataset)
dataset.dataset - Dataset to be evaluatedList object storing the unique Integer
class values of the datasetpublic static void shuffleTimeSeriesDataset(TimeSeriesDataset dataset, int seed)
TimeSeriesDataset object using the given
seed.dataset - The dataset to be shuffledseed - The seed used within the randomized shufflingpublic static ai.libs.jaicore.basic.sets.Pair<TimeSeriesDataset,TimeSeriesDataset> getTrainingAndTestDataForFold(int fold, int numFolds, double[][] srcValueMatrix, int[] srcTargetMatrix)
TimeSeriesDataset objects representing the
training and test split for the given fold of a cross validation
with numFolds many folds. Data is extracted (and copied) from
the given srcValueMatrix and srcTargetMatrix. The
function uses the two functions
TimeSeriesUtil#selectTrainingDataForFold(int, int, int, int, double[][], int[])
and
TimeSeriesUtil#selectTestDataForFold(int, int, int, int, double[][], int[]).fold - The current fold for which the datasets should be
preparednumFolds - Number of total folds using within the performed cross
validationsrcValueMatrix - Source dataset from which the instances are copiedsrcTargetMatrix - Source targets from which the targets are copiedpublic static TimeSeriesDataset createDatasetForMatrix(int[] targets, double[][]... valueMatrices)
targets - The target values of the instancesvalueMatrices - One or more matrices storing the time series valuesTimeSeriesDataset object constructed out of the
given parameterspublic static TimeSeriesDataset createDatasetForMatrix(double[][]... valueMatrices)
TimeSeriesDataset object given one or multiple
valueMatrices.valueMatrices - One or more matrices storing the time series valuesTimeSeriesDataset object constructed out of the
given parameterspublic static java.lang.String toString(double[] timeSeries)
timeSeries - Time series to print."{1.0, 2.0, 3.0, 4.0}"public static double[] keoghDerivate(double[] t)
f'(n) = \frac{ f(n) - f(n-1) + /frac{f(i+1) - f(i-1)}{2} }{2}t - public static double[] keoghDerivateWithBoundaries(double[] t)
f'(n) = \frac{ f(n) - f(n-1) + /frac{f(i+1) - f(i-1)}{2} }{2}t - public static double[] backwardDifferenceDerivate(double[] t)
t - Time series.public static double[] backwardDifferenceDerivateWithBoundaries(double[] t)
t - Time series.public static double[] forwardDifferenceDerivate(double[] t)
t - public static double[] forwardDifferenceDerivateWithBoundaries(double[] t)
t - public static double[] gulloDerivate(double[] t)
t - public static double[] gulloDerivateWithBoundaries(double[] t)
t - public static double sum(double[] t)
public static double mean(double[] t)
public static double variance(double[] t)
public static double standardDeviation(double[] t)
public static double[] zTransform(double[] t)
public static double[] normalizeByStandardDeviation(double[] t)