OpenNN
2.2
Open Neural Networks Library
|
#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) |
Variables & | operator= (const Variables &) |
bool | operator== (const Variables &) const |
const Vector< Item > & | get_items (void) const |
const Item & | get_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< Use > | arrange_uses (void) const |
Vector< std::string > | write_uses (void) const |
const Use & | get_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< Item > | items |
bool | display |
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.
|
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.
|
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.
new_variables_number | Number of variables. |
Definition at line 45 of file variables.cpp.
|
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.
new_inputs_number | Number of input variables. |
new_targets_number | Number of target variables. |
Definition at line 59 of file variables.cpp.
|
explicit |
XML constructor. It creates a variables object and loads its members from a XML document.
variables_document | TinyXML 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.
other_variables | Variables object to be copied. |
Definition at line 83 of file variables.cpp.
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.
document | XML 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.
i | Index 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.
i | Index 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.
i | Index 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.
i | Index 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.
i | Variable 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.
index | Index of variable. |
Definition at line 431 of file variables.cpp.
Assignment operator. It assigns to the current object the members of an existing variables object.
other_variables | Variables 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.
new_variables_number | Number 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.
inputs_number | Number of input variables. |
targets_number | Number 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.
variables_document | Pointer 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:
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:
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.
i | Index of variable. |
new_description | Description 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.
new_descriptions | Description 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.
new_display | Display value. |
Definition at line 1535 of file variables.cpp.
Sets new variable items in this object.
new_items | Vector 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.
i | Index of variable. |
new_name | Name 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.
new_names | Name 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.
columns_name | Names of columns in the data file. |
nominal_labels | Values 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.
new_units | Units 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.
i | Index of variable. |
new_units | Units 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.
i | Index of variable. |
new_use | Use 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".
i | Index of variable. |
new_use | Use for that variable. |
Definition at line 1110 of file variables.cpp.
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).
new_uses | Vector 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".
new_uses | Vector 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.
new_variables_number | Number 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.
i | Variable 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.
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.