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

#include <instances.h>

Classes

struct  Item
 

Public Types

enum  Use { Unused, Training, Generalization, Testing }
 
enum  SplittingMethod { Sequential, Random }
 

Public Member Functions

 Instances (void)
 
 Instances (const size_t &)
 
 Instances (const tinyxml2::XMLDocument &)
 
 Instances (const Instances &)
 
virtual ~Instances (void)
 
Instancesoperator= (const Instances &)
 
bool operator== (const Instances &) const
 
size_t get_instances_number (void) const
 
bool empty (void) const
 
Vector< Usearrange_uses (void) const
 
Vector< std::string > write_uses (void) const
 
Vector< std::string > write_abbreviated_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
 
size_t count_training_instances_number (void) const
 
size_t count_generalization_instances_number (void) const
 
size_t count_testing_instances_number (void) const
 
size_t count_unused_instances_number (void) const
 
size_t count_used_instances_number (void) const
 
Vector< size_t > count_uses (void) const
 
Vector< size_t > arrange_training_indices (void) const
 
Vector< size_t > arrange_generalization_indices (void) const
 
Vector< size_t > arrange_testing_indices (void) const
 
const bool & get_display (void) const
 
void set (void)
 
void set (const size_t &)
 
void set (const tinyxml2::XMLDocument &)
 
void set_default (void)
 
void set_instances_number (const size_t &)
 
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_training (void)
 
void set_generalization (void)
 
void set_testing (void)
 
void set_display (const bool &)
 
void split_sequential_indices (const double &training_ratio=0.6, const double &generalization_ratio=0.2, const double &testing_ratio=0.2)
 
void split_random_indices (const double &training_ratio=0.6, const double &generalization_ratio=0.2, const double &testing_ratio=0.2)
 
void split_instances (const SplittingMethod &splitting_method=Random, const double &training_ratio=0.6, const double &generalization_ratio=0.2, const double &testing_ratio=0.2)
 
Vector< double > calculate_uses_percentage (void) const
 
void convert_time_series (const size_t &)
 
std::string to_string (void) const
 
void print (void) const
 
tinyxml2::XMLDocument * to_XML (void) const
 
void from_XML (const tinyxml2::XMLDocument &)
 

Static Public Member Functions

static SplittingMethod get_splitting_method (const std::string &)
 

Private Attributes

Vector< Itemitems
 
bool display
 

Detailed Description

This class is used to store information about the instances of a data set. Instances in a data set can be used for training, generalization and testing.

Definition at line 46 of file instances.h.

Member Enumeration Documentation

This is an enumeration of the available methods for dividing the instances into training, generalization and testing subsets.

Definition at line 91 of file instances.h.

This enumeration represents the possible uses of an instance (no use, training, generalization or testing).

Definition at line 86 of file instances.h.

Constructor & Destructor Documentation

OpenNN::Instances::Instances ( void  )
explicit

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

Definition at line 28 of file instances.cpp.

OpenNN::Instances::Instances ( const size_t &  new_instances_number)
explicit

Instances number constructor. It creates a data set object with a given number of instances. It also initializes the rest of class members to their default values.

Parameters
new_instances_numberNumber of instances in the data set.

Definition at line 41 of file instances.cpp.

OpenNN::Instances::Instances ( const tinyxml2::XMLDocument &  instances_document)
explicit

XML constructor. It creates a instances object by loading the object members from a TinyXML document.

Parameters
instances_documentXML document from the TinyXML library.

Definition at line 53 of file instances.cpp.

OpenNN::Instances::Instances ( const Instances other_instances)

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

Parameters
other_instancesInstances object to be copied.

Definition at line 65 of file instances.cpp.

Member Function Documentation

Vector< double > OpenNN::Instances::calculate_uses_percentage ( void  ) const

Returns the percentages of unused, training, generalization and testing instances, respectively.

Definition at line 1281 of file instances.cpp.

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

Converts the instances when the data set is to be used for time series prediction. This method modifies the number of instances. The new number of instances will be instances_number - lags_number.

Definition at line 1304 of file instances.cpp.

size_t OpenNN::Instances::count_unused_instances_number ( void  ) const

Returns the number of instances in the data set which will neither be used for training, generalization or testing.

Definition at line 351 of file instances.cpp.

size_t OpenNN::Instances::count_used_instances_number ( void  ) const

Returns the total number of training, generalization and testing instances, i.e. those which are not "Unused".

Definition at line 374 of file instances.cpp.

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

Returns a vector with the number of training, generalization, testing and unused instances. The size of that vector is therefore four.

Definition at line 455 of file instances.cpp.

void OpenNN::Instances::from_XML ( const tinyxml2::XMLDocument &  instances_document)

Deserializes a TinyXML document into this instances object.

Parameters
instances_documentXML document containing the member data.

Definition at line 916 of file instances.cpp.

const bool & OpenNN::Instances::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 571 of file instances.cpp.

Instances::SplittingMethod OpenNN::Instances::get_splitting_method ( const std::string &  splitting_method)
static

Returns a value of the splitting method enumeration from a string with that method.

Parameters
splitting_methodString with the method for splitting the instances.

Definition at line 130 of file instances.cpp.

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

Returns the use of a single instance.

Parameters
iInstance index.

Definition at line 286 of file instances.cpp.

bool OpenNN::Instances::is_used ( const size_t &  i) const

Returns true if a given instance is to be used for training, generalization or testing, and false if it is to be unused.

Definition at line 333 of file instances.cpp.

Instances & OpenNN::Instances::operator= ( const Instances other_instances)

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

Parameters
other_instancesInstances object to be assigned.

Definition at line 88 of file instances.cpp.

bool OpenNN::Instances::operator== ( const Instances other_instances) 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_instances Instances object to be compared with.

Definition at line 109 of file instances.cpp.

void OpenNN::Instances::set ( const size_t &  new_instances_number)

Sets a new number of instances in the instances object. All the instances are set for training.

Parameters
new_instances_numberNumber of instances.

Definition at line 595 of file instances.cpp.

void OpenNN::Instances::set ( const tinyxml2::XMLDocument &  instances_document)

Sets the instances information members from a XML document.

Parameters
instances_documentPointer to a TinyXML document containing the member data.

Definition at line 608 of file instances.cpp.

void OpenNN::Instances::set_default ( void  )

Sets the default values to this instances object:

  • display: true

Definition at line 623 of file instances.cpp.

void OpenNN::Instances::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 826 of file instances.cpp.

void OpenNN::Instances::set_instances_number ( const size_t &  new_instances_number)

Sets a new number of instances in the data set. All instances are also set for training.

Parameters
new_instances_numberNumber of instances.

Definition at line 838 of file instances.cpp.

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

Sets the use of a single instance.

Parameters
iIndex of instance.
new_useUse for that instance.

Definition at line 731 of file instances.cpp.

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

Sets the use of a single instance from a string.

Parameters
iIndex of instance.
new_useString with the use name ("Training", "Generalization", "Testing" or "Unused")

Definition at line 743 of file instances.cpp.

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

Sets new uses to all the instances from a single vector.

Parameters
new_usesVector of use structures. The size must be equal to the number of instances.

Definition at line 635 of file instances.cpp.

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

Sets new uses to all the instances from a single vector of strings.

Parameters
new_usesVector of use strings. Possible values for the elements are "Training", "Generalization", "Testing" and "Unused". The size must be equal to the number of instances.

Definition at line 672 of file instances.cpp.

void OpenNN::Instances::split_instances ( const SplittingMethod splitting_method = Random,
const double &  training_ratio = 0.6,
const double &  generalization_ratio = 0.2,
const double &  testing_ratio = 0.2 
)

Divides the instances into training, generalization and testing subsets.

Parameters
splitting_methodInstances splitting method (Sequential or Random, Random by default).
training_ratioRatio of training instances (0.6 by default).
generalization_ratioRatio of generalization instances (0.2 by default).
testing_ratioRatio of testing instances (0.2 by default).

Definition at line 1201 of file instances.cpp.

void OpenNN::Instances::split_random_indices ( const double &  training_instances_ratio = 0.6,
const double &  generalization_instances_ratio = 0.2,
const double &  testing_instances_ratio = 0.2 
)

Creates new training, generalization and testing indices at random.

Parameters
training_instances_ratioRatio of training instances in the data set.
generalization_instances_ratioRatio of generalization instances in the data set.
testing_instances_ratioRatio of testing instances in the data set.

Definition at line 1016 of file instances.cpp.

void OpenNN::Instances::split_sequential_indices ( const double &  training_instances_ratio = 0.6,
const double &  generalization_instances_ratio = 0.2,
const double &  testing_instances_ratio = 0.2 
)

Creates new training, generalization and testing indices with sequential indices.

Parameters
training_instances_ratioRatio of training instances in the data set.
generalization_instances_ratioRatio of generalization instances in the data set.
testing_instances_ratioRatio of testing instances in the data set.

Definition at line 1114 of file instances.cpp.

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

Serializes the instances 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 851 of file instances.cpp.

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

Returns a string the use name of a single instance.

Parameters
iInstance index.

Definition at line 297 of file instances.cpp.


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