OpenNN  2.2
Open Neural Networks Library
Classes | Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
OpenNN::Variables Class Reference

#include <variables.h>

Classes

struct  Item
 

Public Types

enum  Use { Input, Target, Unused }
 

Public Member Functions

 Variables (void)
 
 Variables (const size_t &)
 
 Variables (const size_t &, const size_t &)
 
 Variables (const tinyxml2::XMLDocument &)
 
 Variables (const Variables &)
 
virtual ~Variables (void)
 
Variablesoperator= (const Variables &)
 
bool operator== (const Variables &) const
 
const Vector< Item > & get_items (void) const
 
const Itemget_item (const size_t &) const
 
size_t get_variables_number (void) const
 
bool empty (void) const
 
size_t count_used_variables_number (void) const
 
size_t count_unused_variables_number (void) const
 
size_t count_inputs_number (void) const
 
size_t count_targets_number (void) const
 
Vector< size_t > count_uses (void) const
 
Vector< Usearrange_uses (void) const
 
Vector< std::string > write_uses (void) const
 
const Useget_use (const size_t &) const
 
std::string write_use (const size_t &) const
 
bool is_used (const size_t &) const
 
Vector< size_t > arrange_inputs_indices (void) const
 
Vector< size_t > arrange_targets_indices (void) const
 
Vector< std::string > arrange_names (void) const
 
const std::string & get_name (const size_t &) const
 
bool has_names (void) const
 
Vector< std::string > arrange_units (void) const
 
const std::string & get_unit (const size_t &) const
 
Vector< std::string > arrange_descriptions (void) const
 
const std::string & get_description (const size_t &) const
 
const bool & get_display (void) const
 
void set (void)
 
void set (const size_t &)
 
void set (const size_t &, const size_t &)
 
void set (const tinyxml2::XMLDocument &)
 
void set_default (void)
 
void set_variables_number (const size_t &)
 
void set_items (const Vector< Item > &)
 
void set_uses (const Vector< Use > &)
 
void set_uses (const Vector< std::string > &)
 
void set_use (const size_t &, const Use &)
 
void set_use (const size_t &, const std::string &)
 
void set_input (void)
 
void set_target (void)
 
void set_default_uses (void)
 
void set_names (const Vector< std::string > &)
 
void set_name (const size_t &, const std::string &)
 
void set_units (const Vector< std::string > &)
 
void set_units (const size_t &, const std::string &)
 
void set_descriptions (const Vector< std::string > &)
 
void set_description (const size_t &, const std::string &)
 
void set_names (const Vector< std::string > &, const Vector< Vector< std::string > > &)
 
void set_display (const bool &)
 
Matrix< std::string > arrange_information (void) const
 
Vector< std::string > arrange_inputs_units (void) const
 
Vector< std::string > arrange_targets_units (void) const
 
Vector< std::string > arrange_inputs_name (void) const
 
Vector< std::string > arrange_targets_name (void) const
 
Vector< std::string > arrange_inputs_description (void) const
 
Vector< std::string > arrange_targets_description (void) const
 
Matrix< std::string > arrange_inputs_information (void) const
 
Matrix< std::string > arrange_targets_information (void) const
 
void convert_time_series (const size_t &)
 
void convert_autoassociation (void)
 
std::string to_string (void) const
 
tinyxml2::XMLDocument * to_XML (void) const
 
void from_XML (const tinyxml2::XMLDocument &)
 

Static Private Member Functions

static std::string unsigned_to_string (const size_t &)
 
static std::string prepend (const std::string &, const std::string &)
 

Private Attributes

Vector< Itemitems
 
bool display
 

Detailed Description

This class is used to store information about the variables of a data set. Variables in a data set can be used as inputs and targets. This class also stores information about the name, unit and description of all the variables.

Definition at line 50 of file variables.h.

Constructor & Destructor Documentation

OpenNN::Variables::Variables ( void  )
explicit

Default constructor. It creates a variables object with zero variables. It also initializes the rest of class members to their default values.

Definition at line 31 of file variables.cpp.

OpenNN::Variables::Variables ( const size_t &  new_variables_number)
explicit

Variables number constructor. It creates a variables object with a given number of variables. All the variables are set as inputs but the last, which is set as targets. It also initializes the rest of class members to their default values.

Parameters
new_variables_numberNumber of variables.

Definition at line 45 of file variables.cpp.

OpenNN::Variables::Variables ( const size_t &  new_inputs_number,
const size_t &  new_targets_number 
)
explicit

Variables number constructor. It creates a variables object with a given number of input and target variables. It also initializes the rest of class members to their default values.

Parameters
new_inputs_numberNumber of input variables.
new_targets_numberNumber of target variables.

Definition at line 59 of file variables.cpp.

OpenNN::Variables::Variables ( const tinyxml2::XMLDocument &  variables_document)
explicit

XML constructor. It creates a variables object and loads its members from a XML document.

Parameters
variables_documentTinyXML document with the member data.

Definition at line 71 of file variables.cpp.

OpenNN::Variables::Variables ( const Variables other_variables)

Copy constructor. It creates a copy of an existing variables object.

Parameters
other_variablesVariables object to be copied.

Definition at line 83 of file variables.cpp.

Member Function Documentation

Matrix< std::string > OpenNN::Variables::arrange_information ( void  ) const

Returns all the available information about the variables as a matrix of strings. The number of rows is the number of variables. The number of columns is four. Each row contains the information of a single variable (name, units, description and use).

Definition at line 471 of file variables.cpp.

Matrix< std::string > OpenNN::Variables::arrange_inputs_information ( void  ) const

Returns a single matrix with the names, units and descriptions of all the input variables. The number of rows is the number of inputs, and the number of columns is 3.

Definition at line 864 of file variables.cpp.

Matrix< std::string > OpenNN::Variables::arrange_targets_information ( void  ) const

Returns a single matrix with the names, units and descriptions of all the target variables. The number of rows is the number of targets, and the number of columns is 3.

Definition at line 892 of file variables.cpp.

Vector< Variables::Use > OpenNN::Variables::arrange_uses ( void  ) const

Returns a vector containing the use of each variable. The size of the vector is equal to the number of variables.

Definition at line 326 of file variables.cpp.

void OpenNN::Variables::convert_autoassociation ( void  )

Arranges the variables in a proper format for autoassociation. The number of variables is doubled. The first half will be set as inputs, and the second half as targets.

Definition at line 1589 of file variables.cpp.

void OpenNN::Variables::convert_time_series ( const size_t &  lags_number)

Converts the variables when the data set is to be used for time series prediction. This method modifies the number of variables. The new number of variables will be variables_number*(1+lags_number).

Definition at line 1547 of file variables.cpp.

Vector< size_t > OpenNN::Variables::count_uses ( void  ) const

Returns a vector containing the numbers of input, target and unused variables, respectively. The size of that vector is three.

Definition at line 295 of file variables.cpp.

void OpenNN::Variables::from_XML ( const tinyxml2::XMLDocument &  document)

Deserializes a TinyXML document into this variables object.

Parameters
documentXML document containing the member data.

Definition at line 1754 of file variables.cpp.

const std::string & OpenNN::Variables::get_description ( const size_t &  i) const

Returns the description of a single variable in the data set.

Parameters
iIndex of variable.

Definition at line 784 of file variables.cpp.

const bool & OpenNN::Variables::get_display ( void  ) const

Returns true if messages from this class can be displayed on the screen, or false if messages from this class can't be displayed on the screen.

Definition at line 920 of file variables.cpp.

const Variables::Item & OpenNN::Variables::get_item ( const size_t &  i) const

Returns the information about a single variable.

Parameters
iIndex of variable.

Definition at line 167 of file variables.cpp.

const std::string & OpenNN::Variables::get_name ( const size_t &  i) const

Returns the name of a single variable in the data set.

Parameters
iIndex of variable.

Definition at line 565 of file variables.cpp.

const std::string & OpenNN::Variables::get_unit ( const size_t &  i) const

Returns the units of a single variable in the data set.

Parameters
iIndex of variable.

Definition at line 685 of file variables.cpp.

const Variables::Use & OpenNN::Variables::get_use ( const size_t &  i) const

Returns the use of a single variable.

Parameters
iVariable index.

Definition at line 388 of file variables.cpp.

bool OpenNN::Variables::is_used ( const size_t &  index) const

Returns true if the use of a variable is either input or target, and false if it is unused.

Parameters
indexIndex of variable.

Definition at line 431 of file variables.cpp.

Variables & OpenNN::Variables::operator= ( const Variables other_variables)

Assignment operator. It assigns to the current object the members of an existing variables object.

Parameters
other_variablesVariables object to be assigned.

Definition at line 110 of file variables.cpp.

bool OpenNN::Variables::operator== ( const Variables other_variables) const

Equal to operator. It compares this object with another object of the same class. It returns true if the members of the two objects have the same values, and false otherwise. @ param other_variables Variables object to be compared with.

Definition at line 136 of file variables.cpp.

void OpenNN::Variables::set ( const size_t &  new_variables_number)

Sets a new number of variables in the current object. All the variables are set as inputs, but the last one, wich is set as targets.

Parameters
new_variables_numberNumber of variables.

Definition at line 944 of file variables.cpp.

void OpenNN::Variables::set ( const size_t &  inputs_number,
const size_t &  targets_number 
)

Sets new numbers of of inputs and target variables in the current object. The total number of variables is the number of inputs plus the number of targets. The first variables are set as inputs, and last ones are set as targets.

Parameters
inputs_numberNumber of input variables.
targets_numberNumber of target variables.

Definition at line 960 of file variables.cpp.

void OpenNN::Variables::set ( const tinyxml2::XMLDocument &  variables_document)

Sets the variables information members from a XML document.

Parameters
variables_documentPointer to a TinyXML document containing the member data.

Definition at line 985 of file variables.cpp.

void OpenNN::Variables::set_default ( void  )

Sets the default values to the variables object:

  • display: true

Definition at line 1000 of file variables.cpp.

void OpenNN::Variables::set_default_uses ( void  )

Sets the default uses for the input and target variables:

  • Input indices: 0, ..., variables number-2.
  • Target indices: variables number-1.

Definition at line 1194 of file variables.cpp.

void OpenNN::Variables::set_description ( const size_t &  i,
const std::string &  new_description 
)

This method sets the description of a single variable. If the vector of descriptions is zero the rest of elements are initialized as empty strings.

Parameters
iIndex of variable.
new_descriptionDescription of variable.

Definition at line 1398 of file variables.cpp.

void OpenNN::Variables::set_descriptions ( const Vector< std::string > &  new_descriptions)

Sets new descriptions for the variables in the data set from a vector of strings. The size of that vector must be equal to the total number of variables.

Parameters
new_descriptionsDescription of variables.

Definition at line 1361 of file variables.cpp.

void OpenNN::Variables::set_display ( const bool &  new_display)

Sets a new display value. If it is set to true messages from this class are to be displayed on the screen; if it is set to false messages from this class are not to be displayed on the screen.

Parameters
new_displayDisplay value.

Definition at line 1535 of file variables.cpp.

void OpenNN::Variables::set_items ( const Vector< Item > &  new_items)

Sets new variable items in this object.

Parameters
new_itemsVector of item structures to be set.

Definition at line 1011 of file variables.cpp.

void OpenNN::Variables::set_name ( const size_t &  i,
const std::string &  new_name 
)

This method set the name of a single variable. If the vector of names is zero the rest of elements are initialized as empty strings.

Parameters
iIndex of variable.
new_nameName of variable.

Definition at line 1258 of file variables.cpp.

void OpenNN::Variables::set_names ( const Vector< std::string > &  new_names)

Sets new names for the variables in the data set from a vector of strings. The size of that vector must be equal to the total number of variables.

Parameters
new_namesName of variables.

Definition at line 1221 of file variables.cpp.

void OpenNN::Variables::set_names ( const Vector< std::string > &  columns_name,
const Vector< Vector< std::string > > &  nominal_labels 
)

Sets the names of the variables from a vector of vectors of names. This method is used when loading a data file with nominal values.

Parameters
columns_nameNames of columns in the data file.
nominal_labelsValues of all nominal variables in the data file.

Definition at line 1432 of file variables.cpp.

void OpenNN::Variables::set_units ( const Vector< std::string > &  new_units)

Sets new units for the variables in the data set from a vector of strings. The size of that vector must be equal to the total number of variables.

Parameters
new_unitsUnits of variables.

Definition at line 1291 of file variables.cpp.

void OpenNN::Variables::set_units ( const size_t &  i,
const std::string &  new_units 
)

This method set the units of a single variable. If the vector of units is zero the rest of elements are initialized as empty strings.

Parameters
iIndex of variable.
new_unitsUnits of variable.

Definition at line 1328 of file variables.cpp.

void OpenNN::Variables::set_use ( const size_t &  i,
const Use new_use 
)

Sets the use of a single variable.

Parameters
iIndex of variable.
new_useUse for that variable.

Definition at line 1078 of file variables.cpp.

void OpenNN::Variables::set_use ( const size_t &  i,
const std::string &  new_use 
)

Sets the use of a single variable from a string. The possible values for that string are "Unused", "Input" and "Target".

Parameters
iIndex of variable.
new_useUse for that variable.

Definition at line 1110 of file variables.cpp.

void OpenNN::Variables::set_uses ( const Vector< Use > &  new_uses)

Sets new uses for the all the variables from a single vector. It does not modify the other information on the variables (name, units or description).

Parameters
new_usesVector of use elements.

Definition at line 1023 of file variables.cpp.

void OpenNN::Variables::set_uses ( const Vector< std::string > &  new_uses)

Sets new uses for the all the variables from a vector of strings. The possible values for that strings are "Input", "Target" and "Unused".

Parameters
new_usesVector of use strings.

Definition at line 1040 of file variables.cpp.

void OpenNN::Variables::set_variables_number ( const size_t &  new_variables_number)

Sets a new number of variables in the variables object. All variables are set as inputs but the last one, which is set as targets.

Parameters
new_variables_numberNumber of variables.

Definition at line 1616 of file variables.cpp.

tinyxml2::XMLDocument * OpenNN::Variables::to_XML ( void  ) const

Serializes the variables object into a XML document of the TinyXML library. See the OpenNN manual for more information about the format of this document.

Definition at line 1664 of file variables.cpp.

std::string OpenNN::Variables::write_use ( const size_t &  i) const

Returns a string the use of a variable.

Parameters
iVariable index.

Definition at line 399 of file variables.cpp.

Vector< std::string > OpenNN::Variables::write_uses ( void  ) const

Returns a vector of strings with the use of each variable. The size of the vector is equal to the number of variables. The possible values for the elements are "Unused", "Input" and "Target".

Definition at line 347 of file variables.cpp.

Member Data Documentation

Vector<Item> OpenNN::Variables::items
private

Vector of variable items. Each item contains the name, units, description and use of a single variable.

Definition at line 246 of file variables.h.


The documentation for this class was generated from the following files: