java.lang.Object
es.upm.fi.cig.multictbnc.data.representation.Sequence
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 Summary
ConstructorDescriptionSequence
(State stateClassVariables, List<State> observations, String nameTimeVariable, List<Double> timestamps) Constructs aSequence
.Sequence
(String nameTimeVariable, List<String> nameFeatureVariables, List<String> nameClassVariables, double[] timeValues, String[][] featureVariablesValues, String[] classVariablesValues, Map<String, Integer> idxFeatureVariables) Constructs aSequence
.Sequence
(List<String> nameVariables, String nameTimeVariable, List<String> nameClassVariables, List<String[]> dataObservations) Constructs aSequence
.Sequence
(List<String> nameVariables, String nameTimeVariable, List<String> nameClassVariables, List<String> nameFeatureVariables, List<String[]> dataObservations) Constructs aSequence
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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.Returns a Map object with the class variables' names and values.Returns the path of the file from which the sequence was extracted.Retrieves the mapping of feature variable names to their indexes within the sequence.Returns the name of all the variables, including the time variable.Returns the names of the class variables.Returns the names of the feature variables.Returns the name of the time variable.int
Returns the total number of class and feature variables in the sequence.int
Returns the number of observations that the sequence contains.String[]
Gets all the possible states of a specific variable.double
getTimeValue
(int idxObservation) Returns the value of the time variable in a given observation.double[]
Returns the values of the time variable in the sequence.getValueClassVariable
(String nameClassVariable) Returns the values of the specified class variable.getValueFeatureVariable
(int idxObservation, String nameVariable) Returns the value of a certain feature variable for a given observation.String[]
getValuesFeatureVariables
(int idxObservation) Returns the values of all feature variables for a given observation.getValueVariable
(int idxObservation, String nameVariable) Returns the value of a certain variable for a given observation.String[][]
Retrieves the array of values for all variables (excluding the time variable) for each observation in the sequence.void
removeFeatureVariable
(String nameFeature) Removes a feature from the sequence.void
setFilePath
(String filePath) Sets the path of the file from which the sequence was extracted.toString()
-
Constructor Details
-
Sequence
public Sequence(List<String> nameVariables, String nameTimeVariable, List<String> nameClassVariables, List<String[]> dataObservations) throws ErroneousSequenceException Constructs aSequence
. 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 observationsnameTimeVariable
- name of the time variablenameClassVariables
- name of the class variablesdataObservations
- 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 aSequence
. It receives the names of the time, feature and class variables and their observations.- Parameters:
nameTimeVariable
- name of the time variablenameFeatureVariables
- name of the feature variablesnameClassVariables
- name of the class variablestimeValues
- array of time values for the sequencefeatureVariablesValues
- array of feature variable values for the sequenceclassVariablesValues
- array of class variable values for the sequenceidxFeatureVariables
- 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 aSequence
. 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 observationsnameTimeVariable
- name of the time variablenameClassVariables
- names of the class variablesnameFeatureVariables
- names of the feature variablesdataObservations
- 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 aSequence
. This constructor is used by the models to sample sequences.- Parameters:
stateClassVariables
- class configuration of the class variablesobservations
- list ofState
representing the observations of the sequencenameTimeVariable
- name of the time variabletimestamps
- list ofDouble
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
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 addedsequence
- 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
Returns the value of a certain feature variable for a given observation.- Parameters:
idxObservation
- observation indexnameVariable
- name of the variable- Returns:
- value of the feature variable in the observation
-
getNameClassVariables
Returns the names of the class variables.- Returns:
- names of the class variables
-
getNameFeatureVariables
Returns the names of the feature variables.- Returns:
- names of the feature variables.
-
getClassVariables
Returns a Map object with the class variables' names and values.- Returns:
- Map with names and values of the class variables
-
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
Sets the path of the file from which the sequence was extracted.- Parameters:
filePath
- path of the file
-
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
Returns the name of all the variables, including the time variable.- Returns:
- name of all the variables
-
getNameTimeVariable
Returns the name of the time variable.- Returns:
- name of the time variable
-
getStates
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
Returns the value of a certain variable for a given observation.- Parameters:
idxObservation
- observation indexnameVariable
- name of the variable- Returns:
- value of the variable in the observation
-
getValueClassVariable
Returns the values of the specified class variable.- Parameters:
nameClassVariable
- name of the class variable- Returns:
- values of the class variable
-
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
Removes a feature from the sequence.- Parameters:
nameFeature
- name of the feature variable
-
toString
-
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
Returns the values of all feature variables for a given observation.- Parameters:
idxObservation
- observation index- Returns:
- values of the feature variables in the observation
-