Callbacks¶
- class sklearn_genetic.callbacks.base.BaseCallback[source]¶
Base Callback from which all Callbacks must inherit from
- abstract on_step(record=None, logbook=None, estimator=None)[source]¶
- 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: False
Always returns False as this class doesn’t take decisions over the optimization
- 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]¶
- 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: False
Always returns False as this class doesn’t take decisions over the optimization
- class sklearn_genetic.callbacks.DeltaThreshold(threshold, metric: str = 'fitness')[source]¶
Stop the optimization if the absolute difference between the current and last metric less or equals than a threshold
- Parameters
- threshold: float, default=None
Threshold to compare the differences between cross validation scores
- 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]¶
- 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: False
Always returns False as this class doesn’t take decisions over the optimization
- 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, logbook, estimator)[source]¶
- 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: False
Always returns False as this class doesn’t take decisions over the optimization
- 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]¶
- 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: False
Always returns False as this class doesn’t take decisions over the optimization