XCSF  1.4.7
XCSF learning classifier system
CheckpointCallback Class Reference

Callback to save XCSF at some frequency. More...

#include <pybind_callback_checkpoint.h>

Inheritance diagram for CheckpointCallback:
[legend]
Collaboration diagram for CheckpointCallback:
[legend]

Public Member Functions

 CheckpointCallback (py::str monitor, std::string filename, bool save_best_only, int save_freq, bool verbose)
 Constructs a new checkpoint callback. More...
 
void save (struct XCSF *xcsf)
 Saves the state of XCSF. More...
 
bool run (struct XCSF *xcsf, py::dict metrics) override
 Performs callback operations. More...
 
void finish (struct XCSF *xcsf) override
 Executes any tasks at the end of fitting. More...
 
- Public Member Functions inherited from Callback
virtual ~Callback ()
 

Private Attributes

py::str monitor
 Name of the metric to monitor. More...
 
std::string filename
 Name of the file to save XCSF. More...
 
bool save_best_only
 Whether to only save the best population. More...
 
int save_freq
 Trial frequency to (possibly) make checkpoints. More...
 
bool verbose
 Whether to display messages when an action is taken. More...
 
double best_error = std::numeric_limits<double>::max()
 Best error. More...
 
int save_trial = 0
 Trial number the last checkpoint was made. More...
 

Detailed Description

Callback to save XCSF at some frequency.

Definition at line 42 of file pybind_callback_checkpoint.h.

Constructor & Destructor Documentation

◆ CheckpointCallback()

CheckpointCallback::CheckpointCallback ( py::str  monitor,
std::string  filename,
bool  save_best_only,
int  save_freq,
bool  verbose 
)
inline

Constructs a new checkpoint callback.

Parameters
[in]monitorName of the metric to monitor: {"train", "val"}.
[in]filenameName of the file to save XCSF.
[in]save_best_onlyWhether to only save the best population.
[in]save_freqTrial frequency to (possibly) make checkpoints.
[in]verboseWhether to display messages when an action is taken.

Definition at line 53 of file pybind_callback_checkpoint.h.

References monitor, and save_freq.

Member Function Documentation

◆ finish()

void CheckpointCallback::finish ( struct XCSF xcsf)
inlineoverridevirtual

Executes any tasks at the end of fitting.

Parameters
[in]xcsfThe XCSF data structure.

Implements Callback.

Definition at line 117 of file pybind_callback_checkpoint.h.

References save(), and save_best_only.

Here is the call graph for this function:

◆ run()

bool CheckpointCallback::run ( struct XCSF xcsf,
py::dict  metrics 
)
inlineoverridevirtual

Performs callback operations.

Parameters
[in]xcsfThe XCSF data structure.
[in]metricsDictionary of performance metrics.
Returns
Whether to terminate training.

Implements Callback.

Definition at line 94 of file pybind_callback_checkpoint.h.

References best_error, monitor, save(), save_best_only, save_freq, and save_trial.

Here is the call graph for this function:

◆ save()

void CheckpointCallback::save ( struct XCSF xcsf)
inline

Saves the state of XCSF.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 78 of file pybind_callback_checkpoint.h.

References filename, get_timestamp(), and xcsf_save().

Referenced by finish(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ best_error

double CheckpointCallback::best_error = std::numeric_limits<double>::max()
private

Best error.

Definition at line 131 of file pybind_callback_checkpoint.h.

Referenced by run().

◆ filename

std::string CheckpointCallback::filename
private

Name of the file to save XCSF.

Definition at line 126 of file pybind_callback_checkpoint.h.

Referenced by save().

◆ monitor

py::str CheckpointCallback::monitor
private

Name of the metric to monitor.

Definition at line 125 of file pybind_callback_checkpoint.h.

Referenced by CheckpointCallback(), and run().

◆ save_best_only

bool CheckpointCallback::save_best_only
private

Whether to only save the best population.

Definition at line 127 of file pybind_callback_checkpoint.h.

Referenced by finish(), and run().

◆ save_freq

int CheckpointCallback::save_freq
private

Trial frequency to (possibly) make checkpoints.

Definition at line 128 of file pybind_callback_checkpoint.h.

Referenced by CheckpointCallback(), and run().

◆ save_trial

int CheckpointCallback::save_trial = 0
private

Trial number the last checkpoint was made.

Definition at line 132 of file pybind_callback_checkpoint.h.

Referenced by run().

◆ verbose

bool CheckpointCallback::verbose
private

Whether to display messages when an action is taken.

Definition at line 129 of file pybind_callback_checkpoint.h.


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