engine_base#

EvalML 引擎的基类。

模块内容#

类摘要#

EngineBase

EvalML 引擎的基类。

EngineComputation

围绕(可能是异步的)引擎计算结果的包装器。

JobLogger

模仿 python logging.Logger 的行为,但存储所有消息而不是实际记录它们。

函数#

evaluate_pipeline

提交给 submit_evaluation_job 引擎方法使用的函数。

score_pipeline

包装 pipeline.score 方法,以便轻松使用 dask 对管道进行评分。

train_and_score_pipeline

给定一个管道、配置和数据,训练并评分管道,返回 CV 或 TV 分数。

train_pipeline

训练一个管道并在必要时调整阈值。

内容#

class evalml.automl.engine.engine_base.EngineBase[source]#

EvalML 引擎的基类。

方法

setup_job_log

为任务设置日志记录器。

submit_evaluation_job

在 AutoMLSearch 期间提交管道评估任务。

submit_scoring_job

提交管道评分任务。

submit_training_job

提交管道训练任务。

static setup_job_log()[source]#

为任务设置日志记录器。

abstract submit_evaluation_job(self, automl_config, pipeline, X, y, X_holdout=None, y_holdout=None)[source]#

在 AutoMLSearch 期间提交管道评估任务。

abstract submit_scoring_job(self, automl_config, pipeline, X, y, objectives, X_train=None, y_train=None)[source]#

提交管道评分任务。

abstract submit_training_job(self, automl_config, pipeline, X, y, X_holdout=None, y_holdout=None)[source]#

提交管道训练任务。

class evalml.automl.engine.engine_base.EngineComputation[source]#

围绕(可能是异步的)引擎计算结果的包装器。

方法

cancel

取消计算。

done

计算是否完成。

get_result

获取计算结果。将阻塞直到计算完成。

abstract cancel(self)[source]#

取消计算。

abstract done(self)[source]#

计算是否完成。

abstract get_result(self)[source]#

获取计算结果。将阻塞直到计算完成。

Raises Exception: 如果计算失败。返回跟踪信息。

evalml.automl.engine.engine_base.evaluate_pipeline(pipeline, automl_config, X, y, logger, X_holdout=None, y_holdout=None)[source]#

提交给 submit_evaluation_job 引擎方法使用的函数。

参数
  • pipeline (PipelineBase) – 要评分的管道。

  • automl_config (AutoMLConfig) – AutoMLSearch 对象,用于访问配置和错误回调函数。

  • X (pd.DataFrame) – 训练特征。

  • y (pd.Series) – 训练目标。

  • logger – 要写入的日志记录器对象。

  • X_holdout (pd.DataFrame) – 保持集特征。

  • y_holdout (pd.DataFrame) – 保持集目标。

返回

第一项 - 包含 cv_score_mean、cv_scores、training_time 和带有详细信息的 cv_data 结构的字典。

第二项 - 我们训练和评分的管道类。第三项 - 带有所有记录消息的任务日志记录器实例。

返回类型

三个项的元组

class evalml.automl.engine.engine_base.JobLogger[source]#

模仿 python logging.Logger 的行为,但存储所有消息而不是实际记录它们。

这在引擎任务期间使用,以便在任务完成后记录日志消息。这样做是为了将单个任务的所有消息分组到日志中。

方法

debug

在 debug 级别存储消息。

error

在 error 级别存储消息。

info

在 info 级别存储消息。

warning

在 warning 级别存储消息。

write_to_logger

按先进先出 (FIFO) 顺序将所有消息写入日志记录器。

debug(self, msg)[source]#

在 debug 级别存储消息。

error(self, msg)[source]#

在 error 级别存储消息。

info(self, msg)[source]#

在 info 级别存储消息。

warning(self, msg)[source]#

在 warning 级别存储消息。

write_to_logger(self, logger)[source]#

按先进先出 (FIFO) 顺序将所有消息写入日志记录器。

evalml.automl.engine.engine_base.score_pipeline(pipeline, X, y, objectives, X_train=None, y_train=None, X_schema=None, y_schema=None)[source]#

包装 pipeline.score 方法,以便轻松使用 dask 对管道进行评分。

参数
  • pipeline (PipelineBase) – 要评分的管道。

  • X (pd.DataFrame) – 用于评分的特征。

  • y (pd.Series) – 用于计算分数的预测目标。

  • objectives (list[ObjectiveBase]) – 用于评分的目标函数列表。

  • X_train (pd.DataFrame) – 训练特征。用于时间序列的特征工程。

  • y_train (pd.Series) – 训练目标。用于时间序列的特征工程。

  • X_schema (ww.TableSchema) – 特征的 Schema。默认为 None。

  • y_schema (ww.ColumnSchema) – 列的 Schema。默认为 None。

返回

包含管道分数的字典对象。

返回类型

dict

evalml.automl.engine.engine_base.train_and_score_pipeline(pipeline, automl_config, full_X_train, full_y_train, logger, X_holdout=None, y_holdout=None)[source]#

给定一个管道、配置和数据,训练并评分管道,返回 CV 或 TV 分数。

参数
  • pipeline (PipelineBase) – 要评分的管道。

  • automl_config (AutoMLSearch) – AutoMLSearch 对象,用于访问配置和错误回调函数。

  • full_X_train (pd.DataFrame) – 训练特征。

  • full_y_train (pd.Series) – 训练目标。

  • logger – 要写入的日志记录器对象。

  • X_holdout (pd.DataFrame) – 保持集特征。

  • y_holdout (pd.DataFrame) – 保持集目标。

抛出

Exception – 如果数据分割后训练集中存在缺失的目标值。

返回

第一项 - 包含 cv_score_mean、cv_scores、training_time 和带有详细信息的 cv_data 结构的字典。

第二项 - 我们训练和评分的管道类。第三项 - 带有所有记录消息的任务日志记录器实例。

返回类型

三个项的元组

evalml.automl.engine.engine_base.train_pipeline(pipeline, X, y, automl_config, schema=True, get_hashes=False)[source]#

训练一个管道并在必要时调整阈值。

参数
  • pipeline (PipelineBase) – 要训练的管道。

  • X (pd.DataFrame) – 用于训练的特征。

  • y (pd.Series) – 用于训练的预测目标。

  • automl_config (AutoMLSearch) – AutoMLSearch 对象,用于访问配置和错误回调函数。

  • schema (bool) – 是否使用 X 和 y 的 schema。默认为 True。

  • get_hashes (bool) – 是否返回用于训练(以及可能阈值调整)的数据哈希值。默认为 False

返回

一个已训练的管道实例。hash(可选):输入数据索引的哈希值,仅在 get_hashes 为 True 时返回。

返回类型

pipeline (PipelineBase)