问题类型#

支持的机器学习问题类型。

子模块#

包内容#

类摘要#

ProblemTypes

定义支持的机器学习问题类型的枚举。

函数#

detect_problem_type

根据目标确定要解决的问题类型(二元分类、多类分类、回归)。忽略缺失和空数据。

handle_problem_types

通过返回 ProblemTypes 或从字符串转换来处理 problem_type。

is_binary

确定提供的 problem_type 是否为二元分类问题类型。

is_classification

确定提供的 problem_type 是否为分类问题类型。

is_multiclass

确定提供的 problem_type 是否为多类分类问题类型。

is_multiseries

确定提供的 problem_type 是否为多序列时间序列问题类型。

is_regression

确定提供的 problem_type 是否为回归问题类型。

is_time_series

确定提供的 problem_type 是否为时间序列问题类型。

目录#

evalml.problem_types.detect_problem_type(y)[source]#

根据目标确定要解决的问题类型(二元分类、多类分类、回归)。忽略缺失和空数据。

参数

y (pd.Series) – 要预测的目标标签。

返回

ProblemType 枚举

返回类型

ProblemType

示例

>>> y = pd.Series([0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1])
>>> assert detect_problem_type(y) == ProblemTypes.BINARY
...
>>> y = pd.Series([1, 2, 3, 2, 1, 1, 1, 2, 2, 3, 3])
>>> assert detect_problem_type(y) == ProblemTypes.MULTICLASS
...
>>> y = pd.Series([1.6, 4.2, 3.3, 2.9, 4, 1, 5.5, 2, -2, -3.2, 3])
>>> assert detect_problem_type(y) == ProblemTypes.REGRESSION
抛出异常

ValueError – 如果输入少于两个类别。

evalml.problem_types.handle_problem_types(problem_type)[source]#

通过返回 ProblemTypes 或从字符串转换来处理 problem_type。

参数

problem_type (strProblemTypes) – 需要处理的问题类型。

返回

ProblemTypes 枚举

抛出异常
  • KeyError – 如果输入不是有效的 ProblemTypes 枚举值。

  • ValueError – 如果输入不是字符串或 ProblemTypes 对象。

示例

>>> assert handle_problem_types("regression") == ProblemTypes.REGRESSION
>>> assert handle_problem_types("TIME SERIES BINARY") == ProblemTypes.TIME_SERIES_BINARY
>>> assert handle_problem_types("Multiclass") == ProblemTypes.MULTICLASS
evalml.problem_types.is_binary(problem_type)[source]#

确定提供的 problem_type 是否为二元分类问题类型。

参数

problem_type (strProblemTypes) – 监督学习问题类型。有关完整列表,请参阅 evalml.problem_types.ProblemType.all_problem_types。

返回

提供的 problem_type 是否为二元分类问题类型。

返回类型

bool

示例

>>> assert is_binary("Binary")
>>> assert is_binary(ProblemTypes.BINARY)
>>> assert is_binary(ProblemTypes.TIME_SERIES_BINARY)
evalml.problem_types.is_classification(problem_type)[source]#

确定提供的 problem_type 是否为分类问题类型。

参数

problem_type (strProblemTypes) – 监督学习问题类型。有关完整列表,请参阅 evalml.problem_types.ProblemType.all_problem_types。

返回

提供的 problem_type 是否为分类问题类型。

返回类型

bool

示例

>>> assert is_classification("Multiclass")
>>> assert is_classification(ProblemTypes.TIME_SERIES_BINARY)
>>> assert not is_classification(ProblemTypes.REGRESSION)
evalml.problem_types.is_multiclass(problem_type)[source]#

确定提供的 problem_type 是否为多类分类问题类型。

参数

problem_type (strProblemTypes) – 监督学习问题类型。有关完整列表,请参阅 evalml.problem_types.ProblemType.all_problem_types。

返回

提供的 problem_type 是否为多类分类问题类型。

返回类型

bool

示例

>>> assert is_multiclass("Multiclass")
>>> assert is_multiclass(ProblemTypes.MULTICLASS)
>>> assert is_multiclass(ProblemTypes.TIME_SERIES_MULTICLASS)
evalml.problem_types.is_multiseries(problem_type)[source]#

确定提供的 problem_type 是否为多序列时间序列问题类型。

参数

problem_type (strProblemTypes) – 监督学习问题类型。有关完整列表,请参阅 evalml.problem_types.ProblemType.all_problem_types。

返回

提供的 problem_type 是否为多序列时间序列问题类型。

返回类型

bool

evalml.problem_types.is_regression(problem_type)[source]#

确定提供的 problem_type 是否为回归问题类型。

参数

problem_type (strProblemTypes) – 监督学习问题类型。有关完整列表,请参阅 evalml.problem_types.ProblemType.all_problem_types。

返回

提供的 problem_type 是否为回归问题类型。

返回类型

bool

示例

>>> assert is_regression("Regression")
>>> assert is_regression(ProblemTypes.REGRESSION)
>>> assert is_regression(ProblemTypes.TIME_SERIES_REGRESSION)
evalml.problem_types.is_time_series(problem_type)[source]#

确定提供的 problem_type 是否为时间序列问题类型。

参数

problem_type (strProblemTypes) – 监督学习问题类型。有关完整列表,请参阅 evalml.problem_types.ProblemType.all_problem_types。

返回

提供的 problem_type 是否为时间序列问题类型。

返回类型

bool

示例

>>> assert is_time_series("time series regression")
>>> assert is_time_series(ProblemTypes.TIME_SERIES_BINARY)
>>> assert not is_time_series(ProblemTypes.REGRESSION)
class evalml.problem_types.ProblemTypes[source]#

定义支持的机器学习问题类型的枚举。

属性

BINARY

二元分类问题。

MULTICLASS

多类分类问题。

MULTISERIES_TIME_SERIES_REGRESSION

多序列时间序列回归问题。

REGRESSION

回归问题。

TIME_SERIES_BINARY

时间序列二元分类问题。

TIME_SERIES_MULTICLASS

时间序列多类分类问题。

TIME_SERIES_REGRESSION

时间序列回归问题。

方法

all_problem_types

获取所有已定义的问题类型列表。

name

枚举成员的名称。

value

枚举成员的值。

all_problem_types(cls)#

获取所有已定义的问题类型列表。

返回

所有已定义问题类型的列表。

返回类型

list(ProblemTypes)

name(self)#

枚举成员的名称。

value(self)#

枚举成员的值。