utilities 模块

用于验证和转换的实用工具方法。

suppress_stdout_stderr

用于对 stdout 和 stderr 进行“深度抑制”的上下文管理器。

将抑制所有输出,即使输出源自编译的 C/Fortran 子函数。 不会抑制引发的异常,因为异常会在脚本退出之前、上下文管理器退出之后输出到 stderr。

函数

convert_dict_values_to_str

转换字典的值,使每个值都是一个字符串。

convert_dict_values_to_str(input_dict: Dict[Any, Any]) -> Dict[str, str]

参数

input_dict
必需

应转换的字典

返回

一个字典,其中的所有值已转换为字符串

get_default_metric_with_objective

获取给定任务的“指标 -> 目标”字典。

get_default_metric_with_objective(task)

参数

task
必需

字符串“分类”或“回归”

返回

“指标 -> 目标”的字典

get_error_code

从异常生成错误代码。

get_error_code(exception: BaseException, as_hierarchy: bool = False) -> str

参数

exception
必需

导致运行失败的异常。

as_hierarchy
默认值: False

是否应返回完整的错误层次结构

返回

返回包含 error_code 的 str。 如果 as_hierarchy 为 True,则返回的层次结构由“.”联接

get_min_points

返回训练所需的最小数据点数。

get_min_points(window_size: int, lags: List[int], max_horizon: int, cv: Optional[int], n_step: Optional[int] = None) -> int

参数

window_size
必需

滚动窗口大小。

lags
必需

延迟大小。

max_horizon
必需

所需的预测长度。

cv
必需

交叉验证次数。

n_step
默认值: None

一个 CV 折叠和下一个 CV 折叠的 origin_time 之间的周期数。 例如,如果每日数据中 n_step = 3,则每个折叠的原始时间将相隔三天。

返回

最小数据点数。

get_primary_metrics

以列表的形式获取给定任务支持的主要指标。

get_primary_metrics(task: str) -> List[str]

参数

task
str
必需

AutoML 支持的任务类型,如 azureml.automl.core.shared.constants.Tasks 中定义所示

返回

任务支持的主要指标的列表。

get_value_float

将字符串值转换为浮点数。 :param floatstring:要转换的输入值。 :type floatstring:str,:return:已转换的值。 :rtype:float

get_value_float(floatstring: str) -> Optional[Union[float, str]]

参数

floatstring

get_value_from_dict

获取具有名称列表的配置项目的值。

get_value_from_dict(dictionary: Dict[str, Any], names: List[str], default_value: Any) -> Any

参数

dictionary
dict
必需

带有键值对的设置字典,用于查找数据。

names
list[str]
必需

查找 foi 的项的名称列表。

default_value
必需

未找到匹配键值时返回的默认值

返回

返回名称列表中的第一个值。

get_value_int

将字符串值转换为整数。

get_value_int(intstring: str) -> Optional[Union[str, int]]

参数

intstring
str
必需

要转换的输入值。

返回

转换后的值。

返回类型

int

interpret_exception

将异常转换为 AzureMLException。

如果异常已经是已知的类型之一(例如 ServiceException、AzureMLException),则按原样返回异常。

开发注意事项:如果我们看到添加了更多异常或具有针对远程运行与本地运行的新说明,请考虑将此功能转换为其自己的类

interpret_exception(exception: BaseException, is_aml_compute: bool = True, **kwargs: Any) -> Union[azureml._common.exceptions.AzureMLException, azureml._restclient.exceptions.ServiceException]

参数

exception
必需

需要解释的异常对象

is_aml_compute
默认值: True

如果上下文是 AML 计算中的执行服务托管的运行(例如 OSErrors),可能需要根据运行类型以不同方式解释网络错误

kwargs
必需

ErrorDefinition 期望的任何运行时间属性(例如 reference_code)

返回

解释为带有错误代码的 AzureMLException 的异常

is_known_date_time_format

检查给定字符串是否与已知日期时间正则表达式匹配。

is_known_date_time_format(datetime_str: str) -> bool

参数

datetime_str
必需

用于检查它是否为日期的输入字符串

返回

给定字符串是否采用已知的日期时间格式

minimize_or_maximize

选择给定指标的目标。

某些指标应最小化,而某些指标应最大化。:param metric: 要查找的指标的名称,:param task: constants.Tasks 之一。 :return:返回其中一个 constants.OptimizerObjectives。

minimize_or_maximize(metric, task=None)

参数

metric
task
默认值: None
subsampling_recommended(num_samples)

参数

num_samples
int
必需

样本数。

返回

如果建议进行子采样,则为 True,否则为 False。

返回类型

to_ordinal_string

将整数转换为序号字符串。

to_ordinal_string(integer: int) -> str

参数

integer
必需