Class TimeSeriesDataset2


  • public class TimeSeriesDataset2
    extends java.lang.Object
    Dataset 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 the i-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. The i-th entry of this array corresponds to the i-th instance of the dataset.

    • Constructor Summary

      Constructors 
      Constructor Description
      TimeSeriesDataset2​(java.util.List<double[][]> valueMatrices)
      Creates a time series dataset without timestamps for testing.
      TimeSeriesDataset2​(java.util.List<double[][]> valueMatrices, int[] targets)
      Creates a time series dataset withot timestamps for training.
      TimeSeriesDataset2​(java.util.List<double[][]> valueMatrices, java.util.List<double[][]> timestampMatrices)
      Creates a time series dataset with timestamps for testing.
      TimeSeriesDataset2​(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
      void add​(double[][] valueMatrix)
      Add a time series variable without timestamps to the dataset.
      void add​(double[][] valueMatrix, double[][] timestampMatrix)
      Add a time series variable with timestamps to the dataset.
      int getNumberOfInstances()
      Returns the number of instances contained in the dataset.
      int getNumberOfVariables()
      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 for timestampMatrices.
      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 for valueMatrices.
      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.
      boolean isEmpty()
      States whether the dataset is empty, i.e. contains no value matrices, or not.
      boolean isMultivariate()
      States whether the dataset is a univariate dataset, i.e. contains more than one value matrix, or not.
      boolean isTest()
      States whether the dataset is a test dataset, i.e. contains no valid targets after initialization, or not.
      boolean isTrain()
      States whether the dataset is a training dataset, i.e. contains valid targets after initialization, or not.
      boolean isUnivariate()
      States whether the dataset is a univariate dataset, i.e. contains exactly one value matrix, or not.
      void remove​(int index)
      Removes the time series variable at a given index.
      void replace​(int index, double[][] valueMatrix, double[][] timestampMatrix)
      Replaces the time series variable at a given index with a new one.
      void setTargets​(int[] targets)
      Setter for targets.
      void setTimestampMatrices​(java.util.List<double[][]> timestampMatrices)
      Setter for timestampMatrices.
      void setValueMatrices​(java.util.List<double[][]> valueMatrices)
      Setter for valueMatrices.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TimeSeriesDataset2

        public TimeSeriesDataset2​(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.
      • TimeSeriesDataset2

        public TimeSeriesDataset2​(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 - Valueso 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.
      • TimeSeriesDataset2

        public TimeSeriesDataset2​(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.
      • TimeSeriesDataset2

        public TimeSeriesDataset2​(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 index index.
      • 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 index index.
      • 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. Or null, if no value matrix exists at index index.
      • 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. Or null, if no timestamp matrix exists at index index.
      • 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 for valueMatrices.
        Returns:
        the valueMatrices
      • getTimestampMatrices

        public java.util.List<double[][]> getTimestampMatrices()
        Getter for timestampMatrices.
        Returns:
        the timestampMatrices
      • setValueMatrices

        public void setValueMatrices​(java.util.List<double[][]> valueMatrices)
        Setter for valueMatrices.
        Parameters:
        valueMatrices - the valueMatrices to set
      • setTimestampMatrices

        public void setTimestampMatrices​(java.util.List<double[][]> timestampMatrices)
        Setter for timestampMatrices.
        Parameters:
        timestampMatrices - the timestampMatrices to set
      • setTargets

        public void setTargets​(int[] targets)
        Setter for targets.
        Parameters:
        targets - the targets to set