OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
opennn::InputsSelection Class Referenceabstract

Abstract base class for input feature selection methods. More...

#include <inputs_selection.h>

Inheritance diagram for opennn::InputsSelection:
[legend]

Public Types

enum class  StoppingCondition {
  MaximumTime , SelectionErrorGoal , MaximumInputs , MaximumEpochs ,
  MaximumSelectionFailures
}
 Reasons that can terminate an input-selection run. More...
 

Public Member Functions

 InputsSelection (TrainingStrategy *training_strategy=nullptr)
 Constructs the selector.
 
virtual ~InputsSelection ()=default
 Virtual destructor.
 
const TrainingStrategyget_training_strategy () const
 Read-only access to the bound training strategy.
 
bool has_training_strategy () const
 Whether a training strategy has been bound.
 
bool get_display () const
 Whether progress should be printed to stdout.
 
virtual Index get_minimum_inputs_number () const =0
 Lower bound on the number of selected inputs in any candidate.
 
virtual Index get_maximum_inputs_number () const =0
 Upper bound on the number of selected inputs in any candidate.
 
void set (TrainingStrategy *new_training_strategy)
 Re-initializes the selector by setting its training strategy.
 
void set_trials_number (const Index new_trials_number)
 Sets the number of training trials per candidate (mean is used).
 
void set_display (bool new_display)
 Toggles per-iteration progress printing.
 
void set_validation_error_goal (const float new_validation_error_goal)
 Sets the validation error goal.
 
void set_maximum_epochs (const Index new_maximum_epochs)
 Sets the maximum training epochs per evaluation.
 
void set_maximum_validation_failures (const Index new_maximum_validation_failures)
 Sets the maximum number of consecutive validation-error increases tolerated.
 
void set_maximum_time (const float new_maximum_time)
 Sets the maximum wall-clock selection time.
 
void check () const
 Validates the bound configuration; throws if anything is missing.
 
virtual InputsSelectionResults perform_input_selection ()=0
 Runs the selection algorithm.
 
string get_name () const
 Canonical name of the selector (set by subclasses).
 
virtual void from_JSON (const JsonDocument &)=0
 Loads selector hyperparameters from a parsed JSON document.
 
virtual void to_JSON (JsonWriter &) const =0
 Writes selector hyperparameters to a streaming JSON writer.
 
void save (const filesystem::path &) const
 Saves the selector configuration to a file.
 
void load (const filesystem::path &)
 Loads the selector configuration from a file.
 
virtual void print () const
 Prints a human-readable summary of the selector to stdout.
 

Protected Attributes

TrainingStrategytraining_strategy = nullptr
 Training strategy used to evaluate candidate subsets; not owned.
 
Index trials_number = 1
 Number of independent training runs averaged per candidate.
 
bool display = true
 Whether progress should be printed to stdout during selection.
 
float validation_error_goal
 Validation error goal; selection stops when reached.
 
Index maximum_epochs
 Maximum training epochs per evaluation.
 
Index maximum_validation_failures = 100
 Maximum consecutive validation-error increases tolerated.
 
float maximum_time
 Maximum wall-clock selection time in seconds.
 
string name
 Canonical name of the selector (set by subclasses).
 

Detailed Description

Abstract base class for input feature selection methods.

Holds a pointer to a TrainingStrategy used to evaluate candidate input subsets, the common stopping criteria (epoch budget, time budget, validation goal, validation failure budget) and trial averaging. Subclasses implement perform_input_selection() to drive the search.

Member Enumeration Documentation

◆ StoppingCondition

Reasons that can terminate an input-selection run.

Enumerator
MaximumTime 

Configured time budget exhausted.

SelectionErrorGoal 

Validation error reached the configured goal.

MaximumInputs 

Maximum number of input variables reached.

MaximumEpochs 

Configured epoch budget exhausted.

MaximumSelectionFailures 

Validation error increased too many times.

Constructor & Destructor Documentation

◆ InputsSelection()

opennn::InputsSelection::InputsSelection ( TrainingStrategy * training_strategy = nullptr)

Constructs the selector.

Parameters
training_strategyTraining strategy used to evaluate candidate subsets.

◆ ~InputsSelection()

virtual opennn::InputsSelection::~InputsSelection ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ check()

void opennn::InputsSelection::check ( ) const

Validates the bound configuration; throws if anything is missing.

◆ from_JSON()

virtual void opennn::InputsSelection::from_JSON ( const JsonDocument & )
pure virtual

Loads selector hyperparameters from a parsed JSON document.

Implemented in opennn::GeneticAlgorithm, and opennn::GrowingInputs.

◆ get_display()

bool opennn::InputsSelection::get_display ( ) const
inline

Whether progress should be printed to stdout.

◆ get_maximum_inputs_number()

virtual Index opennn::InputsSelection::get_maximum_inputs_number ( ) const
pure virtual

Upper bound on the number of selected inputs in any candidate.

Implemented in opennn::GeneticAlgorithm, and opennn::GrowingInputs.

◆ get_minimum_inputs_number()

virtual Index opennn::InputsSelection::get_minimum_inputs_number ( ) const
pure virtual

Lower bound on the number of selected inputs in any candidate.

Implemented in opennn::GeneticAlgorithm, and opennn::GrowingInputs.

◆ get_name()

string opennn::InputsSelection::get_name ( ) const
inline

Canonical name of the selector (set by subclasses).

◆ get_training_strategy()

const TrainingStrategy * opennn::InputsSelection::get_training_strategy ( ) const
inline

Read-only access to the bound training strategy.

◆ has_training_strategy()

bool opennn::InputsSelection::has_training_strategy ( ) const
inline

Whether a training strategy has been bound.

◆ load()

void opennn::InputsSelection::load ( const filesystem::path & )

Loads the selector configuration from a file.

Receives the source path.

◆ perform_input_selection()

virtual InputsSelectionResults opennn::InputsSelection::perform_input_selection ( )
pure virtual

Runs the selection algorithm.

Returns
Best-of-run input subset and supporting statistics.

Implemented in opennn::GeneticAlgorithm, and opennn::GrowingInputs.

◆ print()

virtual void opennn::InputsSelection::print ( ) const
inlinevirtual

Prints a human-readable summary of the selector to stdout.

◆ save()

void opennn::InputsSelection::save ( const filesystem::path & ) const

Saves the selector configuration to a file.

Receives the destination path.

◆ set()

void opennn::InputsSelection::set ( TrainingStrategy * new_training_strategy)
inline

Re-initializes the selector by setting its training strategy.

Parameters
new_training_strategyStrategy used to evaluate candidates.

◆ set_display()

void opennn::InputsSelection::set_display ( bool new_display)
inline

Toggles per-iteration progress printing.

Parameters
new_displayTrue to print progress to stdout.

◆ set_maximum_epochs()

void opennn::InputsSelection::set_maximum_epochs ( const Index new_maximum_epochs)
inline

Sets the maximum training epochs per evaluation.

Parameters
new_maximum_epochsEpoch budget for each candidate's training.

◆ set_maximum_time()

void opennn::InputsSelection::set_maximum_time ( const float new_maximum_time)
inline

Sets the maximum wall-clock selection time.

Parameters
new_maximum_timeTime budget in seconds.

◆ set_maximum_validation_failures()

void opennn::InputsSelection::set_maximum_validation_failures ( const Index new_maximum_validation_failures)
inline

Sets the maximum number of consecutive validation-error increases tolerated.

Parameters
new_maximum_validation_failuresFailure budget for early stopping.

◆ set_trials_number()

void opennn::InputsSelection::set_trials_number ( const Index new_trials_number)
inline

Sets the number of training trials per candidate (mean is used).

Parameters
new_trials_numberNumber of independent training runs averaged.

◆ set_validation_error_goal()

void opennn::InputsSelection::set_validation_error_goal ( const float new_validation_error_goal)
inline

Sets the validation error goal.

Parameters
new_validation_error_goalSelection stops when validation error reaches this value.

◆ to_JSON()

virtual void opennn::InputsSelection::to_JSON ( JsonWriter & ) const
pure virtual

Writes selector hyperparameters to a streaming JSON writer.

Implemented in opennn::GeneticAlgorithm, and opennn::GrowingInputs.

Member Data Documentation

◆ display

bool opennn::InputsSelection::display = true
protected

Whether progress should be printed to stdout during selection.

◆ maximum_epochs

Index opennn::InputsSelection::maximum_epochs
protected

Maximum training epochs per evaluation.

◆ maximum_time

float opennn::InputsSelection::maximum_time
protected

Maximum wall-clock selection time in seconds.

◆ maximum_validation_failures

Index opennn::InputsSelection::maximum_validation_failures = 100
protected

Maximum consecutive validation-error increases tolerated.

◆ name

string opennn::InputsSelection::name
protected

Canonical name of the selector (set by subclasses).

◆ training_strategy

TrainingStrategy* opennn::InputsSelection::training_strategy = nullptr
protected

Training strategy used to evaluate candidate subsets; not owned.

◆ trials_number

Index opennn::InputsSelection::trials_number = 1
protected

Number of independent training runs averaged per candidate.

◆ validation_error_goal

float opennn::InputsSelection::validation_error_goal
protected

Validation error goal; selection stops when reached.