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
必需
|
字符串“classification”或“regression” |
返回
| 类型 | 说明 |
|---|---|
|
指标字典 -> 目标 |
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: int | None, n_step: int | None = None) -> int
参数
| 名称 | 说明 |
|---|---|
|
window_size
必需
|
滚动窗口大小。 |
|
lags
必需
|
滞后大小。 |
|
max_horizon
必需
|
预测的所需长度。 |
|
cv
必需
|
交叉验证数。 |
|
n_step
|
一个 CV 折叠的origin_time和下一个折叠之间的句点数。 例如,如果 n_step = 3 表示每日数据,则每个折叠的起始时间将相隔三天。 默认值: None
|
返回
| 类型 | 说明 |
|---|---|
|
最小数据点数。 |
get_primary_metrics
获取给定任务支持的主要指标作为列表。
get_primary_metrics(task: str) -> List[str]
参数
| 名称 | 说明 |
|---|---|
|
task
必需
|
AutoML 支持的任务类型,如 azureml.automl.core.shared.constants.Tasks 中定义 |
返回
| 类型 | 说明 |
|---|---|
|
任务支持的主要指标的列表。 |
get_value_float
将字符串值转换为 float。 :p aram floatstring:要转换的输入值。 :type floatstring: str :return: 转换后的值。 :rtype: float
get_value_float(floatstring: str) -> float | str | None
参数
| 名称 | 说明 |
|---|---|
|
floatstring
必需
|
|
get_value_from_dict
get_value_int
interpret_exception
将异常转换为 AzureMLException。
如果异常已是已知类型之一(例如 ServiceException、AzureMLException),则返回异常 as-is。
开发说明:如果看到为远程与本地运行添加更多异常或新的解释,请考虑将此功能转换为其自己的类
interpret_exception(exception: BaseException, is_aml_compute: bool = True, **kwargs: Any) -> AzureMLException | ServiceException
参数
| 名称 | 说明 |
|---|---|
|
exception
必需
|
需要解释的异常对象 |
|
is_aml_compute
|
如果上下文是在 AML 计算上运行的执行服务托管运行(例如 OSErrors),则可能需要根据运行类型以不同的方式解释网络错误) 默认值: True
|
|
kwargs
必需
|
ErrorDefinition 需要的任何运行时属性(如reference_code) |
返回
| 类型 | 说明 |
|---|---|
|
异常解释为带有错误代码的 AzureMLException |
is_known_date_time_format
检查给定字符串是否与已知日期时间正则表达式匹配。
is_known_date_time_format(datetime_str: str) -> bool
参数
| 名称 | 说明 |
|---|---|
|
datetime_str
必需
|
要检查其是否为日期的输入字符串 |
返回
| 类型 | 说明 |
|---|---|
|
给定字符串是否采用已知日期时间格式 |
minimize_or_maximize
选择给定指标的目标。
某些指标应最小化,某些指标应最大化:p aram 指标:要查找:p aram 任务的指标的名称:常量之一。任务。 :return: 返回一个常量。OptimizerObjectives。
minimize_or_maximize(metric, task=None)
参数
| 名称 | 说明 |
|---|---|
|
metric
必需
|
|
|
task
|
默认值: None
|
subsampling_recommended
to_ordinal_string
将整数转换为序号字符串。
to_ordinal_string(integer: int) -> str
参数
| 名称 | 说明 |
|---|---|
|
integer
必需
|
|