Callbacks

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)[source]
Parameters
record: dict: default=None

A logbook record

logbook:

Current stream logbook with the stats required

Returns
decision: bool

True if the optimization algorithm must stop, false otherwise

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)[source]
Parameters
record: dict: default=None

A logbook record

logbook:

Current stream logbook with the stats required

Returns
decision: bool

True if the optimization algorithm must stop, false otherwise

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)[source]
Parameters
record: dict: default=None

A logbook record

logbook:

Current stream logbook with the stats required

Returns
decision: bool

True if the optimization algorithm must stop, false otherwise