java.lang.Object
es.upm.fi.cig.multictbnc.data.representation.Sequence

public class Sequence extends Object
Represents a sequence of multivariate data, i.e., a set of data points with multiple variables where the order is relevant. In this case, a sequence represents a time series since the data is ordered by a time variable.
  • Constructor Details

    • Sequence

      public Sequence(List<String> nameVariables, String nameTimeVariable, List<String> nameClassVariables, List<String[]> dataObservations) throws ErroneousSequenceException
      Constructs a Sequence. It receives the names of all the variables and those that are time and class variables, and the observations of the sequence.
      Parameters:
      nameVariables - names of all the variables in the sequence. It is assumed that they are presented in the same order as they appear in the data of the observations
      nameTimeVariable - name of the time variable
      nameClassVariables - name of the class variables
      dataObservations - list of arrays with the values of the observations
      Throws:
      ErroneousSequenceException - if a valid sequence cannot be created with the provided data
    • Sequence

      public Sequence(String nameTimeVariable, List<String> nameFeatureVariables, List<String> nameClassVariables, double[] timeValues, String[][] featureVariablesValues, String[] classVariablesValues, Map<String,Integer> idxFeatureVariables)
      Constructs a Sequence. It receives the names of the time, feature and class variables and their observations.
      Parameters:
      nameTimeVariable - name of the time variable
      nameFeatureVariables - name of the feature variables
      nameClassVariables - name of the class variables
      timeValues - array of time values for the sequence
      featureVariablesValues - array of feature variable values for the sequence
      classVariablesValues - array of class variable values for the sequence
      idxFeatureVariables - mapping of feature variable names to their indexes
    • Sequence

      public Sequence(List<String> nameVariables, String nameTimeVariable, List<String> nameClassVariables, List<String> nameFeatureVariables, List<String[]> dataObservations) throws ErroneousSequenceException
      Constructs a Sequence. It receives the names of all the variables and the observations of the sequence.
      Parameters:
      nameVariables - names of all the variables in the sequence. It is assumed that they are presented in the same order as they appear in the data of the observations
      nameTimeVariable - name of the time variable
      nameClassVariables - names of the class variables
      nameFeatureVariables - names of the feature variables
      dataObservations - list of arrays with the values of the observations
      Throws:
      ErroneousSequenceException - if a valid sequence cannot be created with the provided data
    • Sequence

      public Sequence(State stateClassVariables, List<State> observations, String nameTimeVariable, List<Double> timestamps) throws ErroneousSequenceException
      Constructs a Sequence. This constructor is used by the models to sample sequences.
      Parameters:
      stateClassVariables - class configuration of the class variables
      observations - list of State representing the observations of the sequence
      nameTimeVariable - name of the time variable
      timestamps - list of Double representing the timestamps when each observation of the sequence was obtained
      Throws:
      ErroneousSequenceException - if a valid sequence cannot be created with the provided data
  • Method Details

    • addFeatureVariable

      public boolean addFeatureVariable(String nameFeatureVariable, Sequence sequence)
      Adds a new feature variable to the sequence by copying the values from another sequence with the same number of observations.
      Parameters:
      nameFeatureVariable - name of the new feature variable to be added
      sequence - sequence containing the values of the new feature variable for each observation
      Returns:
      true if the addition was successful, false otherwise
    • getNumObservations

      public int getNumObservations()
      Returns the number of observations that the sequence contains.
      Returns:
      number of observations
    • getNumClassAndFeatureVariables

      public int getNumClassAndFeatureVariables()
      Returns the total number of class and feature variables in the sequence.
      Returns:
      total number of class and feature variables in the sequence
    • getValueFeatureVariable

      public String getValueFeatureVariable(int idxObservation, String nameVariable)
      Returns the value of a certain feature variable for a given observation.
      Parameters:
      idxObservation - observation index
      nameVariable - name of the variable
      Returns:
      value of the feature variable in the observation
    • getNameClassVariables

      public List<String> getNameClassVariables()
      Returns the names of the class variables.
      Returns:
      names of the class variables
    • getNameFeatureVariables

      public List<String> getNameFeatureVariables()
      Returns the names of the feature variables.
      Returns:
      names of the feature variables.
    • getClassVariables

      public Map<String,String> getClassVariables()
      Returns a Map object with the class variables' names and values.
      Returns:
      Map with names and values of the class variables
    • getFilePath

      public String getFilePath()
      Returns the path of the file from which the sequence was extracted.
      Returns:
      path of the file from which the sequence was extracted
    • setFilePath

      public void setFilePath(String filePath)
      Sets the path of the file from which the sequence was extracted.
      Parameters:
      filePath - path of the file
    • getIdxFeatureVariables

      public Map<String,Integer> getIdxFeatureVariables()
      Retrieves the mapping of feature variable names to their indexes within the sequence.
      Returns:
      Map where keys are the names of the feature variables and values are their corresponding indexes in the observations.
    • getNameAllVariables

      public List<String> getNameAllVariables()
      Returns the name of all the variables, including the time variable.
      Returns:
      name of all the variables
    • getNameTimeVariable

      public String getNameTimeVariable()
      Returns the name of the time variable.
      Returns:
      name of the time variable
    • getStates

      public String[] getStates(String nameVariable)
      Gets all the possible states of a specific variable. Returns null if the variable does not exist or was ignored.
      Parameters:
      nameVariable - name of the variable whose possible states we want to know
      Returns:
      Array with the states of the variable
    • getTimeValues

      public double[] getTimeValues()
      Returns the values of the time variable in the sequence.
      Returns:
      values of the time variable in the sequence
    • getValueVariable

      public String getValueVariable(int idxObservation, String nameVariable)
      Returns the value of a certain variable for a given observation.
      Parameters:
      idxObservation - observation index
      nameVariable - name of the variable
      Returns:
      value of the variable in the observation
    • getValueClassVariable

      public String getValueClassVariable(String nameClassVariable)
      Returns the values of the specified class variable.
      Parameters:
      nameClassVariable - name of the class variable
      Returns:
      values of the class variable
    • getVariablesValues

      public String[][] getVariablesValues()
      Retrieves the array of values for all variables (excluding the time variable) for each observation in the sequence.
      Returns:
      array of String where each row represents an observation and each column represents a variable's value at that observation
    • removeFeatureVariable

      public void removeFeatureVariable(String nameFeature)
      Removes a feature from the sequence.
      Parameters:
      nameFeature - name of the feature variable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getTimeValue

      public double getTimeValue(int idxObservation)
      Returns the value of the time variable in a given observation.
      Parameters:
      idxObservation - observation index
      Returns:
      value of the time variable
    • getValuesFeatureVariables

      public String[] getValuesFeatureVariables(int idxObservation)
      Returns the values of all feature variables for a given observation.
      Parameters:
      idxObservation - observation index
      Returns:
      values of the feature variables in the observation