Callbacks
Base Callback from which all Callbacks must inherit from |
|
|
Displays a tqdm progress bar with the training progress. |
|
Stop the optimization if the current metric value is no greater that at least one metric from the last N generations |
|
Stops the optimization if the absolute difference between the maximum and minimum value from the last N generations is less or equals to a threshold. |
|
Stops the optimization process if a limit training time has been elapsed. |
|
Stop the optimization if the metric from cross validation score is greater or equals than the define threshold |
|
Log all the fitness metrics to Tensorboard into log_dir/run_id folder |
|
Saves the estimator.logbook parameter chapter object in a local file system. |
- class sklearn_genetic.callbacks.base.BaseCallback[source]
Base Callback from which all Callbacks must inherit from
- on_end(logbook=None, estimator=None)[source]
Take actions at the end of the training
- Parameters:
- logbook:
Current stream logbook with the stats required
- estimator:
GASearchCV
Estimator that is being optimized
- on_start(estimator=None)[source]
Take actions at the start of the training
- Parameters:
- estimator:
GASearchCV
Estimator that is being optimized
- on_step(record=None, logbook=None, estimator=None)[source]
Take actions after fitting each generation.
- Parameters:
- record: dict: default=None
A logbook record
- logbook:
Current stream logbook with the stats required
- estimator:
GASearchCV
Estimator that is being optimized
- Returns:
- decision: bool, default=False
If
True
, the optimization process is stopped, else, if continues to the next generation.
- class sklearn_genetic.callbacks.ProgressBar(**kwargs)[source]
Displays a tqdm progress bar with the training progress.
- Parameters:
- kwargs: dict, default = {“file”: sys.stdout}
A dict with valid arguments from tqdm.auto.tqdm
- class sklearn_genetic.callbacks.ConsecutiveStopping(generations, metric='fitness')[source]
Stop the optimization if the current metric value is no greater that at least one metric from the last N generations
- Parameters:
- generations: int, default=None
Number of current generations to compare against current generation
- metric: {‘fitness’, ‘fitness_std’, ‘fitness_max’, ‘fitness_min’}, default =’fitness’
Name of the metric inside ‘record’ logged in each iteration
- on_step(record=None, logbook=None, estimator=None)[source]
Take actions after fitting each generation.
- Parameters:
- record: dict: default=None
A logbook record
- logbook:
Current stream logbook with the stats required
- estimator:
GASearchCV
Estimator that is being optimized
- Returns:
- decision: bool, default=False
If
True
, the optimization process is stopped, else, if continues to the next generation.
- class sklearn_genetic.callbacks.DeltaThreshold(threshold, generations=2, metric: str = 'fitness')[source]
Stops the optimization if the absolute difference between the maximum and minimum value from the last N generations is less or equals to a threshold. The threshold gets evaluated after the number of generations specified is reached.
- Parameters:
- threshold: float, default=None
Threshold to compare the differences between cross-validation scores.
- generations: int, default=2
Number of generations to compare, includes the current generation.
- metric: {‘fitness’, ‘fitness_std’, ‘fitness_max’, ‘fitness_min’}, default =’fitness’
Name of the metric inside ‘record’ logged in each iteration.
- on_step(record=None, logbook=None, estimator=None)[source]
Take actions after fitting each generation.
- Parameters:
- record: dict: default=None
A logbook record
- logbook:
Current stream logbook with the stats required
- estimator:
GASearchCV
Estimator that is being optimized
- Returns:
- decision: bool, default=False
If
True
, the optimization process is stopped, else, if continues to the next generation.
- class sklearn_genetic.callbacks.TimerStopping(total_seconds)[source]
Stops the optimization process if a limit training time has been elapsed. This time is checked after each generation fit
- Parameters:
- total_seconds: int
Total time in seconds that the estimator is allowed to fit
- on_start(estimator=None)[source]
Take actions at the start of the training
- Parameters:
- estimator:
GASearchCV
Estimator that is being optimized
- on_step(record=None, logbook=None, estimator=None)[source]
Take actions after fitting each generation.
- Parameters:
- record: dict: default=None
A logbook record
- logbook:
Current stream logbook with the stats required
- estimator:
GASearchCV
Estimator that is being optimized
- Returns:
- decision: bool, default=False
If
True
, the optimization process is stopped, else, if continues to the next generation.
- class sklearn_genetic.callbacks.ThresholdStopping(threshold, metric='fitness')[source]
Stop the optimization if the metric from cross validation score is greater or equals than the define threshold
- Parameters:
- threshold: float, default=None
Threshold to compare against the current cross validation average score and determine if the optimization process must stop
- metric: {‘fitness’, ‘fitness_std’, ‘fitness_max’, ‘fitness_min’}, default =’fitness’
Name of the metric inside ‘record’ logged in each iteration
- on_step(record=None, logbook=None, estimator=None)[source]
Take actions after fitting each generation.
- Parameters:
- record: dict: default=None
A logbook record
- logbook:
Current stream logbook with the stats required
- estimator:
GASearchCV
Estimator that is being optimized
- Returns:
- decision: bool, default=False
If
True
, the optimization process is stopped, else, if continues to the next generation.
- class sklearn_genetic.callbacks.TensorBoard(log_dir='./logs', run_id=None)[source]
Log all the fitness metrics to Tensorboard into log_dir/run_id folder
- Parameters:
- log_dir: str, default=”./logs”
Path to the main folder where the data will be log
- run_id: str, default=None
Subfolder where the data will be log, if None it will create a folder with the current datetime with format time.strftime(“%Y_%m_%d-%H_%M_%S”)
- on_step(record=None, logbook=None, estimator=None)[source]
Take actions after fitting each generation.
- Parameters:
- record: dict: default=None
A logbook record
- logbook:
Current stream logbook with the stats required
- estimator:
GASearchCV
Estimator that is being optimized
- Returns:
- decision: bool, default=False
If
True
, the optimization process is stopped, else, if continues to the next generation.
- class sklearn_genetic.callbacks.LogbookSaver(checkpoint_path, **dump_options)[source]
Saves the estimator.logbook parameter chapter object in a local file system.
- Parameters:
- checkpoint_path: str
Location where checkpoint will be saved to
- dump_options, str
Valid kwargs from joblib
dump
- on_step(record=None, logbook=None, estimator=None)[source]
Take actions after fitting each generation.
- Parameters:
- record: dict: default=None
A logbook record
- logbook:
Current stream logbook with the stats required
- estimator:
GASearchCV
Estimator that is being optimized
- Returns:
- decision: bool, default=False
If
True
, the optimization process is stopped, else, if continues to the next generation.