Class TimeSeriesDataset
- java.lang.Object
-
- ai.libs.jaicore.ml.tsc.dataset.TimeSeriesDataset
-
public class TimeSeriesDataset extends java.lang.ObjectDataset for time series.The dataset consists of a value matrices and timestamp matrices. In the univariate case, there exists one value matrix, either with or without a corresponding timestamp matrix. In the multivariate case there exists multiple value matrices, each either with or without a corresponding timestamp matrix. Each value matrix is associated with an integer index. Each timestamp matrix is associated with an integer index. Two corresponding value and timestamp matrices are associated with the same index. The dimensions of two corresponding value and timestamp matrices are assured to be the same. All value matrices have the same number of rows, but not necessarily the same number of columns. The
i-th row of each matrix corresponds to thei-th instance of the dataset.The targets contained in this dataset are always integers. The can be mapped back and forth with the
ClassMapper. Targets are represented as an integer array. Thei-th entry of this array corresponds to thei-th instance of the dataset.
-
-
Constructor Summary
Constructors Constructor Description TimeSeriesDataset(java.util.List<double[][]> valueMatrices)Creates a time series dataset without timestamps for testing.TimeSeriesDataset(java.util.List<double[][]> valueMatrices, int[] targets)Creates a time series dataset withot timestamps for training.TimeSeriesDataset(java.util.List<double[][]> valueMatrices, java.util.List<double[][]> timestampMatrices)Creates a time series dataset with timestamps for testing.TimeSeriesDataset(java.util.List<double[][]> valueMatrices, java.util.List<double[][]> timestampMatrices, int[] targets)Creates a time series dataset with timestamps for training.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(double[][] valueMatrix)Add a time series variable without timestamps to the dataset.voidadd(double[][] valueMatrix, double[][] timestampMatrix)Add a time series variable with timestamps to the dataset.intgetNumberOfInstances()Returns the number of instances contained in the dataset.intgetNumberOfVariables()Returns the number of variables, i.e. the number of value matrices contained in the dataset.int[]getTargets()Getter for the target values.java.util.List<double[][]>getTimestampMatrices()Getter fortimestampMatrices.double[][]getTimestamps(int index)Getter for the timestamp matrix at a specific index.double[][]getTimestampsOrNull(int index)Getter for the timestamp matrix at a specific index.java.util.List<double[][]>getValueMatrices()Getter forvalueMatrices.double[][]getValues(int index)Getter for the value matrix at a specific index.double[][]getValuesOrNull(int index)Getter for the value matrix at a specific index.booleanisEmpty()States whether the dataset is empty, i.e. contains no value matrices, or not.booleanisMultivariate()States whether the dataset is a univariate dataset, i.e. contains more than one value matrix, or not.booleanisTest()States whether the dataset is a test dataset, i.e. contains no valid targets after initialization, or not.booleanisTrain()States whether the dataset is a training dataset, i.e. contains valid targets after initialization, or not.booleanisUnivariate()States whether the dataset is a univariate dataset, i.e. contains exactly one value matrix, or not.voidremove(int index)Removes the time series variable at a given index.voidreplace(int index, double[][] valueMatrix, double[][] timestampMatrix)Replaces the time series variable at a given index with a new one.voidsetTargets(int[] targets)Setter fortargets.voidsetTimestampMatrices(java.util.List<double[][]> timestampMatrices)Setter fortimestampMatrices.voidsetValueMatrices(java.util.List<double[][]> valueMatrices)Setter forvalueMatrices.
-
-
-
Constructor Detail
-
TimeSeriesDataset
public TimeSeriesDataset(java.util.List<double[][]> valueMatrices, java.util.List<double[][]> timestampMatrices, int[] targets)Creates a time series dataset with timestamps for training. Let `n` be the number of instances.- Parameters:
valueMatrices- Values for the time series variables. List of 2D-Arrays with shape `[n, ?]`.timestampMatrices- Timestamps for the time series variables. List of 2D-Arrays with shape `[n, ?]`. Or `null` if no timestamps exist for the corresponding time series variable. The shape of the `i`th index must be equal to the shape of the `i`th element of `valueMatrices`.targets- Target values for the instances.
-
TimeSeriesDataset
public TimeSeriesDataset(java.util.List<double[][]> valueMatrices, java.util.List<double[][]> timestampMatrices)Creates a time series dataset with timestamps for testing. Let `n` be the number of instances.- Parameters:
valueMatrices- Values for the time series variables. List of 2D-Arrays with shape `[n, ?]`.timestampMatrices- Timestamps for the time series variables. List of 2D-Arrays with shape `[n, ?]`. Or `null` if no timestamps exist for the corresponding time series variable. The shape of the `i`th index must be equal to the shape of the `i`th element of `valueMatrices`.targets- Target values for the instances.
-
TimeSeriesDataset
public TimeSeriesDataset(java.util.List<double[][]> valueMatrices, int[] targets)Creates a time series dataset withot timestamps for training. Let `n` be the number of instances.- Parameters:
valueMatrices- Values for the time series variables. List of 2D-Arrays with shape `[n, ?]`.timestampMatrices- Timestamps for the time series variables. List of 2D-Arrays with shape `[n, ?]`. Or `null` if no timestamps exist for the corresponding time series variable. The shape of the `i`th index must be equal to the shape of the `i`th element of `valueMatrices`.targets- Target values for the instances.
-
TimeSeriesDataset
public TimeSeriesDataset(java.util.List<double[][]> valueMatrices)
Creates a time series dataset without timestamps for testing. Let `n` be the number of instances.- Parameters:
valueMatrices- Values for the time series variables. List of 2D-Arrays with shape `[n, ?]`.targets- Target values for the instances.
-
-
Method Detail
-
add
public void add(double[][] valueMatrix, double[][] timestampMatrix)Add a time series variable with timestamps to the dataset.- Parameters:
valueMatrix- Values for the time series variable to add. 2D-Arrays with shape `[n, ?]` where `n` is the number of instances of the dataset.timestampMatrix- Timestamps for the time series variable to add. 2D-Arrays with shape `[n, ?]` where `n` is the number of instances of the dataset. Or `null` if no timestamp exists for this time series variable.
-
add
public void add(double[][] valueMatrix)
Add a time series variable without timestamps to the dataset.- Parameters:
valueMatrix- Values for the time series variable to add. 2D-Arrays with shape `[n, ?]` where `n` is the number of instances of the dataset.
-
remove
public void remove(int index)
Removes the time series variable at a given index.- Parameters:
index-- Throws:
java.lang.IndexOutOfBoundsException
-
replace
public void replace(int index, double[][] valueMatrix, double[][] timestampMatrix)Replaces the time series variable at a given index with a new one.- Parameters:
index- Index of the time series varialbe to replace.valueMatrix- Values for the time series variable to add. 2D-Arrays with shape `[n, ?]` where `n` is the number of instances of the dataset.timestampMatrix- Timestamps for the time series variable to add. 2D-Arrays with shape `[n, ?]` where `n` is the number of instances of the dataset. Or `null` if no timestamp exists for this time series variable.- Throws:
java.lang.IndexOutOfBoundsException- Thrown if `numberOfInstances <= index`.
-
getTargets
public int[] getTargets()
Getter for the target values.- Returns:
- The targets.
-
getNumberOfVariables
public int getNumberOfVariables()
Returns the number of variables, i.e. the number of value matrices contained in the dataset.- Returns:
- The number of variables.
-
getNumberOfInstances
public int getNumberOfInstances()
Returns the number of instances contained in the dataset.- Returns:
- The number of instances contained in the dataset.
-
getValues
public double[][] getValues(int index)
Getter for the value matrix at a specific index. Throws an exception if no timestamp matrix exists at this index.- Parameters:
index- The index of the value matrix.- Returns:
- The value matrix at index
index. - Throws:
java.lang.IndexOutOfBoundsException- If there is no value matrix at indexindex.
-
getTimestamps
public double[][] getTimestamps(int index)
Getter for the timestamp matrix at a specific index.- Parameters:
index- The index of the timestamp matrix.- Returns:
- The timestamp matrix at index
index. - Throws:
java.lang.IndexOutOfBoundsException- If there is no value timestamp at indexindex.
-
getValuesOrNull
public double[][] getValuesOrNull(int index)
Getter for the value matrix at a specific index.- Parameters:
index- The index of the timestamp matrix.- Returns:
- The value matrix at index
index. Ornull, if no value matrix exists at indexindex.
-
getTimestampsOrNull
public double[][] getTimestampsOrNull(int index)
Getter for the timestamp matrix at a specific index.- Parameters:
index- The index of the timestamp matrix.- Returns:
- The timestamp matrix at index
index. Ornull, if no timestamp matrix exists at indexindex.
-
isEmpty
public boolean isEmpty()
States whether the dataset is empty, i.e. contains no value matrices, or not.- Returns:
True, if the dataset is empty.False, otherwise.
-
isUnivariate
public boolean isUnivariate()
States whether the dataset is a univariate dataset, i.e. contains exactly one value matrix, or not.- Returns:
True, if the dataset is univariate.False, otherwise.
-
isMultivariate
public boolean isMultivariate()
States whether the dataset is a univariate dataset, i.e. contains more than one value matrix, or not.- Returns:
True, if the dataset is multivariate.False, otherwise.
-
isTrain
public boolean isTrain()
States whether the dataset is a training dataset, i.e. contains valid targets after initialization, or not.- Returns:
True, if the dataset is a training dataset.False, otherwise.
-
isTest
public boolean isTest()
States whether the dataset is a test dataset, i.e. contains no valid targets after initialization, or not.- Returns:
True, if the dataset is a test dataset.False, otherwise.
-
getValueMatrices
public java.util.List<double[][]> getValueMatrices()
Getter forvalueMatrices.- Returns:
- the valueMatrices
-
getTimestampMatrices
public java.util.List<double[][]> getTimestampMatrices()
Getter fortimestampMatrices.- Returns:
- the timestampMatrices
-
setValueMatrices
public void setValueMatrices(java.util.List<double[][]> valueMatrices)
Setter forvalueMatrices.- Parameters:
valueMatrices- the valueMatrices to set
-
setTimestampMatrices
public void setTimestampMatrices(java.util.List<double[][]> timestampMatrices)
Setter fortimestampMatrices.- Parameters:
timestampMatrices- the timestampMatrices to set
-
setTargets
public void setTargets(int[] targets)
Setter fortargets.- Parameters:
targets- the targets to set
-
-