ModelSelection Class Reference

This class represents the concept of model selection[1] algorithm in OpenNN. More...

#include <model_selection.h>

Classes

struct  Results
 This structure contains the results from the model selection process. More...
 

Public Types

enum  OrderSelectionMethod { NO_NEURONS_SELECTION, INCREMENTAL_NEURONS }
 Enumeration of all the available order selection algorithms.
 
enum  InputsSelectionMethod { NO_INPUTS_SELECTION, GROWING_INPUTS, PRUNING_INPUTS, GENETIC_ALGORITHM }
 Enumeration of all the available inputs selection algorithms.
 

Public Member Functions

 ModelSelection ()
 Default constructor.
 
 ModelSelection (TrainingStrategy *)
 
 ModelSelection (const string &)
 
 ModelSelection (const tinyxml2::XMLDocument &)
 
virtual ~ModelSelection ()
 Destructor.
 
TrainingStrategyget_training_strategy_pointer () const
 Returns a pointer to the training strategy object.
 
bool has_training_strategy () const
 
const OrderSelectionMethodget_neurons_selection_method () const
 Returns the type of algorithm for the order selection.
 
const InputsSelectionMethodget_inputs_selection_method () const
 Returns the type of algorithm for the inputs selection.
 
IncrementalNeuronsget_incremental_neurons_pointer () const
 Returns a pointer to the incremental order selection algorithm.
 
GrowingInputsget_growing_inputs_pointer () const
 Returns a pointer to the growing inputs selection algorithm.
 
PruningInputsget_pruning_inputs_pointer () const
 Returns a pointer to the pruning inputs selection algorithm.
 
GeneticAlgorithmget_genetic_algorithm_pointer () const
 Returns a pointer to the genetic inputs selection algorithm.
 
void set_default ()
 Sets the members of the model selection object to their default values.
 
void set_display (const bool &)
 
void set_training_strategy_pointer (TrainingStrategy *)
 
void set_neurons_selection_method (const OrderSelectionMethod &)
 
void set_neurons_selection_method (const string &)
 
void set_inputs_selection_method (const InputsSelectionMethod &)
 
void set_inputs_selection_method (const string &)
 
void set_approximation (const bool &)
 
void destruct_neurons_selection ()
 This method deletes the order selection algorithm object which composes this model selection object.
 
void destruct_inputs_selection ()
 This method deletes the inputs selection algorithm object which composes this model selection object.
 
Vector< NeuralNetworkperform_k_fold_cross_validation (const size_t &=4) const
 
Vector< NeuralNetworkperform_random_cross_validation (const size_t &=4, const double &=0.25) const
 
Vector< NeuralNetworkperform_positives_cross_validation () const
 
void check () const
 Checks that the different pointers needed for performing the model selection are not nullptr.
 
Results perform_neurons_selection () const
 
Results perform_inputs_selection () const
 
Results perform_model_selection () const
 
tinyxml2::XMLDocumentto_XML () const
 
void from_XML (const tinyxml2::XMLDocument &)
 
void write_XML (tinyxml2::XMLPrinter &) const
 
void print () const
 Prints to the screen the XML representation of this model selection object.
 
void save (const string &) const
 
void load (const string &)
 

Private Attributes

TrainingStrategytraining_strategy_pointer = nullptr
 Pointer to a training strategy object.
 
IncrementalNeuronsincremental_neurons_pointer = nullptr
 Pointer to a incremental order object to be used for order selection.
 
GrowingInputsgrowing_inputs_pointer = nullptr
 Pointer to a growing inputs object to be used for inputs selection.
 
PruningInputspruning_inputs_pointer = nullptr
 Pointer to a pruning inputs object to be used for inputs selection.
 
GeneticAlgorithmgenetic_algorithm_pointer = nullptr
 Pointer to a genetic algorithm object to be used for inputs selection.
 
OrderSelectionMethod neurons_selection_method
 Type of order selection algorithm.
 
InputsSelectionMethod inputs_selection_method
 Type of inputs selection algorithm.
 
bool display
 Display messages to screen.
 

Detailed Description

This class represents the concept of model selection[1] algorithm in OpenNN.

It is used for finding a network architecture with maximum generalization capabilities.

[1] Neural Designer "Model Selection Algorithms in Predictive Analytics." https://www.neuraldesigner.com/blog/model-selection

Definition at line 40 of file model_selection.h.

Constructor & Destructor Documentation

◆ ModelSelection() [1/3]

ModelSelection ( TrainingStrategy new_training_strategy_pointer)
explicit

Training strategy constructor.

Parameters
new_training_strategy_pointerPointer to a training strategy object.

Definition at line 31 of file model_selection.cpp.

◆ ModelSelection() [2/3]

ModelSelection ( const string &  file_name)
explicit

File constructor.

Parameters
file_nameName of XML model selection file.

Definition at line 46 of file model_selection.cpp.

◆ ModelSelection() [3/3]

ModelSelection ( const tinyxml2::XMLDocument model_selection_document)
explicit

XML constructor.

Parameters
model_selection_documentPointer to a TinyXML document containing the model selection data.

Definition at line 61 of file model_selection.cpp.

Member Function Documentation

◆ from_XML()

void from_XML ( const tinyxml2::XMLDocument document)

Loads the members of this model selection object from a XML document.

Parameters
documentXML document of the TinyXML library.

Definition at line 892 of file model_selection.cpp.

◆ has_training_strategy()

bool has_training_strategy ( ) const

Returns true if this model selection has a training strategy associated, and false otherwise.

Definition at line 115 of file model_selection.cpp.

◆ load()

void load ( const string &  file_name)

Loads the model selection members from a XML file.

Parameters
file_nameName of model selection XML file.

Definition at line 1039 of file model_selection.cpp.

◆ perform_inputs_selection()

ModelSelection::Results perform_inputs_selection ( ) const

Perform the inputs selection, returns a structure with the results of the inputs selection. It also set the neural network of the training strategy pointer with the optimum parameters.

Definition at line 622 of file model_selection.cpp.

◆ perform_k_fold_cross_validation()

Vector< NeuralNetwork > perform_k_fold_cross_validation ( const size_t &  k = 4) const
Todo:

Definition at line 1111 of file model_selection.cpp.

◆ perform_model_selection()

ModelSelection::Results perform_model_selection ( ) const

Perform inputs selection and order selection.

Todo:

Definition at line 665 of file model_selection.cpp.

◆ perform_neurons_selection()

ModelSelection::Results perform_neurons_selection ( ) const

Perform the order selection, returns a structure with the results of the order selection. It also set the neural network of the training strategy pointer with the optimum parameters.

Definition at line 595 of file model_selection.cpp.

◆ perform_positives_cross_validation()

Vector< NeuralNetwork > perform_positives_cross_validation ( ) const
Todo:
Check this method.

Definition at line 1311 of file model_selection.cpp.

◆ perform_random_cross_validation()

Vector< NeuralNetwork > perform_random_cross_validation ( const size_t &  k = 4,
const double &  selection_ratio = 0.25 
) const
Todo:

Definition at line 1207 of file model_selection.cpp.

◆ save()

void save ( const string &  file_name) const

Saves the model selection members to a XML file.

Parameters
file_nameName of model selection XML file.

Definition at line 1026 of file model_selection.cpp.

◆ set_approximation()

void set_approximation ( const bool &  new_approximation)

Sets a new approximation method. If it is set to true the problem will be taken as a approximation; if it is set to false the problem will be taken as a classification.

Parameters
new_approximationApproximation value.

Definition at line 402 of file model_selection.cpp.

◆ set_display()

void 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 193 of file model_selection.cpp.

◆ set_inputs_selection_method() [1/2]

void set_inputs_selection_method ( const InputsSelectionMethod new_inputs_selection_method)

Sets a new method for selecting the inputs which have more impact on the targets.

Parameters
new_inputs_selection_methodMethod for selecting the inputs(NO_INPUTS_SELECTION, GROWING_INPUTS, PRUNING_INPUTS, GENETIC_ALGORITHM).

Definition at line 312 of file model_selection.cpp.

◆ set_inputs_selection_method() [2/2]

void set_inputs_selection_method ( const string &  new_inputs_selection_method)

Sets a new inputs selection algorithm from a string.

Parameters
new_inputs_selection_methodString with the inputs selection type.

Definition at line 366 of file model_selection.cpp.

◆ set_neurons_selection_method() [1/2]

void set_neurons_selection_method ( const OrderSelectionMethod new_neurons_selection_method)

Sets a new method for selecting the order which have more impact on the targets.

Parameters
new_neurons_selection_methodMethod for selecting the order(NO_NEURONS_SELECTION, INCREMENTAL_NEURONS, GOLDEN_SECTION, SIMULATED_ANNEALING).

Definition at line 246 of file model_selection.cpp.

◆ set_neurons_selection_method() [2/2]

void set_neurons_selection_method ( const string &  new_neurons_selection_method)

Sets a new order selection algorithm from a string.

Parameters
new_neurons_selection_methodString with the order selection type.

Definition at line 286 of file model_selection.cpp.

◆ set_training_strategy_pointer()

void set_training_strategy_pointer ( TrainingStrategy new_training_strategy_pointer)

Sets a new training strategy pointer.

Parameters
new_training_strategy_pointerPointer to a training strategy object.

Definition at line 437 of file model_selection.cpp.

◆ to_XML()

tinyxml2::XMLDocument * to_XML ( ) const

Serializes the model selection 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 676 of file model_selection.cpp.

◆ write_XML()

void write_XML ( tinyxml2::XMLPrinter file_stream) const

Serializes the model selection object into a XML document of the TinyXML library without keep the DOM tree in memory. See the OpenNN manual for more information about the format of this document.

Definition at line 803 of file model_selection.cpp.


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