回调函数

base.BaseCallback()

所有回调函数必须继承的基础回调类

ProgressBar(**kwargs)

显示一个带有训练进度的tqdm进度条。

ConsecutiveStopping(generations[, metric])

如果当前指标值不大于最近N代中的至少一个指标值,则停止优化

DeltaThreshold(threshold[, generations, metric])

如果最近N代的最大值与最小值之间的绝对差小于或等于阈值,则停止优化。

TimerStopping(total_seconds)

如果达到预设的训练时间限制,则停止优化过程。

ThresholdStopping(threshold[, metric])

如果交叉验证分数的指标大于或等于定义的阈值,则停止优化

TensorBoard([log_dir, run_id])

将所有适应度指标记录到Tensorboard的log_dir/run_id文件夹中

LogbookSaver(检查点路径, **转储选项)

将estimator.logbook参数章节对象保存到本地文件系统中。

class sklearn_genetic.callbacks.base.BaseCallback[源代码]

所有回调函数必须继承的基础回调类

on_end(logbook=None, estimator=None)[源代码]

在训练结束时采取行动

Parameters:
logbook:

当前流日志记录包含所需统计信息

estimator:

GASearchCV 正在优化的估计器

on_start(estimator=None)[源代码]

在训练开始时采取行动

Parameters:
estimator:

GASearchCV 正在优化的估计器

on_step(record=None, logbook=None, estimator=None)[源代码]

在拟合每一代后执行操作。

Parameters:
record: dict: default=None

日志记录

logbook:

当前流日志记录包含所需统计信息

estimator:

GASearchCV 正在优化的估计器

Returns:
decision: bool, default=False

如果 True,则停止优化过程,否则继续下一代。

class sklearn_genetic.callbacks.ProgressBar(**kwargs)[源代码]

显示一个带有训练进度的tqdm进度条。

Parameters:
kwargs: dict, default = {“file”: sys.stdout}

一个包含来自 tqdm.auto.tqdm 的有效参数的字典

on_end(logbook=None, estimator=None)[源代码]

关闭进度条

on_start(estimator=None)[源代码]

使用kwargs和总代数初始化进度条

on_step(record=None, logbook=None, estimator=None)[源代码]

将进度条增加一步

class sklearn_genetic.callbacks.ConsecutiveStopping(generations, metric='fitness')[源代码]

如果当前指标值不大于最近N代中的至少一个指标值,则停止优化

Parameters:
generations: int, default=None

用于与当前世代进行比较的过往世代数量

metric: {‘fitness’, ‘fitness_std’, ‘fitness_max’, ‘fitness_min’}, default =’fitness’

每次迭代中记录的'metric'名称

on_step(record=None, logbook=None, estimator=None)[源代码]

在拟合每一代后执行操作。

Parameters:
record: dict: default=None

日志记录

logbook:

当前流日志记录包含所需统计信息

estimator:

GASearchCV 正在优化的估计器

Returns:
decision: bool, default=False

如果 True,则停止优化过程,否则继续下一代。

class sklearn_genetic.callbacks.DeltaThreshold(threshold, generations=2, metric: str = 'fitness')[源代码]

当最近N代的最大值与最小值之间的绝对差小于或等于阈值时,停止优化。 在达到指定的代数后,将评估该阈值。

Parameters:
threshold: float, default=None

用于比较交叉验证分数差异的阈值。

generations: int, default=2

要比较的代数数量,包括当前代数。

metric: {‘fitness’, ‘fitness_std’, ‘fitness_max’, ‘fitness_min’}, default =’fitness’

每次迭代中记录的'metric'名称。

on_step(record=None, logbook=None, estimator=None)[源代码]

在拟合每一代后执行操作。

Parameters:
record: dict: default=None

日志记录

logbook:

当前流日志记录包含所需统计信息

estimator:

GASearchCV 正在优化的估计器

Returns:
decision: bool, default=False

如果 True,则停止优化过程,否则继续下一代。

class sklearn_genetic.callbacks.TimerStopping(total_seconds)[源代码]

如果达到预设的训练时间限制,则停止优化过程。 每次生成拟合后会检查该时间限制

Parameters:
total_seconds: int

允许估计器进行拟合的总时间(秒)

on_start(estimator=None)[源代码]

在训练开始时采取行动

Parameters:
estimator:

GASearchCV 正在优化的估计器

on_step(record=None, logbook=None, estimator=None)[源代码]

在拟合每一代后执行操作。

Parameters:
record: dict: default=None

日志记录

logbook:

当前流日志记录包含所需统计信息

estimator:

GASearchCV 正在优化的估计器

Returns:
decision: bool, default=False

如果 True,则停止优化过程,否则继续下一代。

class sklearn_genetic.callbacks.ThresholdStopping(threshold, metric='fitness')[源代码]

当交叉验证分数指标达到或超过定义的阈值时,停止优化

Parameters:
threshold: float, default=None

用于与当前交叉验证平均分数进行比较的阈值,以确定是否需要停止优化过程

metric: {‘fitness’, ‘fitness_std’, ‘fitness_max’, ‘fitness_min’}, default =’fitness’

每次迭代中记录的'metric'名称

on_step(record=None, logbook=None, estimator=None)[源代码]

在拟合每一代后执行操作。

Parameters:
record: dict: default=None

日志记录

logbook:

当前流日志记录包含所需统计信息

estimator:

GASearchCV 正在优化的估计器

Returns:
decision: bool, default=False

如果 True,则停止优化过程,否则继续下一代。

class sklearn_genetic.callbacks.TensorBoard(log_dir='./logs', run_id=None)[源代码]

将所有适应度指标记录到Tensorboard的log_dir/run_id文件夹中

Parameters:
log_dir: str, default=”./logs”

数据日志的主文件夹路径

run_id: str, default=None

数据将被记录的子文件夹,如果为None,则会创建一个以当前日期时间命名的文件夹,格式为time.strftime("%Y_%m_%d-%H_%M_%S")

on_step(record=None, logbook=None, estimator=None)[源代码]

在拟合每一代后执行操作。

Parameters:
record: dict: default=None

日志记录

logbook:

当前流日志记录包含所需统计信息

estimator:

GASearchCV 正在优化的估计器

Returns:
decision: bool, default=False

如果 True,则停止优化过程,否则继续下一代。

class sklearn_genetic.callbacks.LogbookSaver(checkpoint_path, **dump_options)[源代码]

将estimator.logbook参数章节对象保存到本地文件系统中。

Parameters:
checkpoint_path: str

检查点保存的位置

dump_options, str

来自 joblib dump 的有效 kwargs

on_step(record=None, logbook=None, estimator=None)[源代码]

在拟合每一代后执行操作。

Parameters:
record: dict: default=None

日志记录

logbook:

当前流日志记录包含所需统计信息

estimator:

GASearchCV 正在优化的估计器

Returns:
decision: bool, default=False

如果 True,则停止优化过程,否则继续下一代。