utils¶
Utility methods for the ProblemTypes enum in EvalML.
Module Contents¶
Functions¶
Determine the type of problem is being solved based on the targets (binary vs multiclass classification, regression). Ignores missing and null data. |
|
Handles problem_type by either returning the ProblemTypes or converting from a str. |
|
Determines if the provided problem_type is a binary classification problem type. |
|
Determines if the provided problem_type is a classification problem type. |
|
Determines if the provided problem_type is a multiclass classification problem type. |
|
Determines if the provided problem_type is a regression problem type. |
|
Determines if the provided problem_type is a time series problem type. |
Contents¶
-
evalml.problem_types.utils.
detect_problem_type
(y)[source]¶ Determine the type of problem is being solved based on the targets (binary vs multiclass classification, regression). Ignores missing and null data.
- Parameters
y (pd.Series) – The target labels to predict.
- Returns
ProblemType Enum
- Return type
ProblemType
Examples
>>> 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
- Raises
ValueError – If the input has less than two classes.
-
evalml.problem_types.utils.
handle_problem_types
(problem_type)[source]¶ Handles problem_type by either returning the ProblemTypes or converting from a str.
- Parameters
problem_type (str or ProblemTypes) – Problem type that needs to be handled.
- Returns
ProblemTypes enum
- Raises
KeyError – If input is not a valid ProblemTypes enum value.
ValueError – If input is not a string or ProblemTypes object.
Examples
>>> 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.utils.
is_binary
(problem_type)[source]¶ Determines if the provided problem_type is a binary classification problem type.
- Parameters
problem_type (str or ProblemTypes) – type of supervised learning problem. See evalml.problem_types.ProblemType.all_problem_types for a full list.
- Returns
Whether or not the provided problem_type is a binary classification problem type.
- Return type
bool
Examples
>>> assert is_binary("Binary") >>> assert is_binary(ProblemTypes.BINARY) >>> assert is_binary(ProblemTypes.TIME_SERIES_BINARY)
-
evalml.problem_types.utils.
is_classification
(problem_type)[source]¶ Determines if the provided problem_type is a classification problem type.
- Parameters
problem_type (str or ProblemTypes) – type of supervised learning problem. See evalml.problem_types.ProblemType.all_problem_types for a full list.
- Returns
Whether or not the provided problem_type is a classification problem type.
- Return type
bool
Examples
>>> assert is_classification("Multiclass") >>> assert is_classification(ProblemTypes.TIME_SERIES_BINARY) >>> assert not is_classification(ProblemTypes.REGRESSION)
-
evalml.problem_types.utils.
is_multiclass
(problem_type)[source]¶ Determines if the provided problem_type is a multiclass classification problem type.
- Parameters
problem_type (str or ProblemTypes) – type of supervised learning problem. See evalml.problem_types.ProblemType.all_problem_types for a full list.
- Returns
Whether or not the provided problem_type is a multiclass classification problem type.
- Return type
bool
Examples
>>> assert is_multiclass("Multiclass") >>> assert is_multiclass(ProblemTypes.MULTICLASS) >>> assert is_multiclass(ProblemTypes.TIME_SERIES_MULTICLASS)
-
evalml.problem_types.utils.
is_regression
(problem_type)[source]¶ Determines if the provided problem_type is a regression problem type.
- Parameters
problem_type (str or ProblemTypes) – type of supervised learning problem. See evalml.problem_types.ProblemType.all_problem_types for a full list.
- Returns
Whether or not the provided problem_type is a regression problem type.
- Return type
bool
Examples
>>> assert is_regression("Regression") >>> assert is_regression(ProblemTypes.REGRESSION) >>> assert is_regression(ProblemTypes.TIME_SERIES_REGRESSION)
-
evalml.problem_types.utils.
is_time_series
(problem_type)[source]¶ Determines if the provided problem_type is a time series problem type.
- Parameters
problem_type (str or ProblemTypes) – type of supervised learning problem. See evalml.problem_types.ProblemType.all_problem_types for a full list.
- Returns
Whether or not the provided problem_type is a time series problem type.
- Return type
bool
Examples
>>> assert is_time_series("time series regression") >>> assert is_time_series(ProblemTypes.TIME_SERIES_BINARY) >>> assert not is_time_series(ProblemTypes.REGRESSION)