automl_algorithm¶
AutoML algorithms that power EvalML.
Package Contents¶
Classes Summary¶
Base class for the AutoML algorithms which power EvalML. |
|
An automl algorithm that consists of two modes: fast and long, where fast is a subset of long. |
|
An automl algorithm which first fits a base round of pipelines with default parameters, then does a round of parameter tuning on each pipeline in order of performance. |
Exceptions Summary¶
Contents¶
-
class
evalml.automl.automl_algorithm.
AutoMLAlgorithm
(allowed_pipelines=None, custom_hyperparameters=None, tuner_class=None, text_in_ensembling=False, random_seed=0, n_jobs=- 1)[source]¶ Base class for the AutoML algorithms which power EvalML.
This class represents an automated machine learning (AutoML) algorithm. It encapsulates the decision-making logic behind an automl search, by both deciding which pipelines to evaluate next and by deciding what set of parameters to configure the pipeline with.
To use this interface, you must define a next_batch method which returns the next group of pipelines to evaluate on the training data. That method may access state and results recorded from the previous batches, although that information is not tracked in a general way in this base class. Overriding add_result is a convenient way to record pipeline evaluation info if necessary.
- Parameters
allowed_pipelines (list(class)) – A list of PipelineBase subclasses indicating the pipelines allowed in the search. The default of None indicates all pipelines for this problem type are allowed.
custom_hyperparameters (dict) – Custom hyperparameter ranges specified for pipelines to iterate over.
tuner_class (class) – A subclass of Tuner, to be used to find parameters for each pipeline. The default of None indicates the SKOptTuner will be used.
text_in_ensembling (boolean) – If True and ensembling is True, then n_jobs will be set to 1 to avoid downstream sklearn stacking issues related to nltk. Defaults to None.
random_seed (int) – Seed for the random number generator. Defaults to 0.
Methods
Register results from evaluating a pipeline.
Returns the number of batches which have been recommended so far.
Returns the number of max batches AutoMLSearch should run by default.
Get the next batch of pipelines to evaluate.
Returns the number of pipelines which have been recommended so far.
-
add_result
(self, score_to_minimize, pipeline, trained_pipeline_results)[source]¶ Register results from evaluating a pipeline.
- Parameters
score_to_minimize (float) – The score obtained by this pipeline on the primary objective, converted so that lower values indicate better pipelines.
pipeline (PipelineBase) – The trained pipeline object which was used to compute the score.
trained_pipeline_results (dict) – Results from training a pipeline.
- Raises
PipelineNotFoundError – If pipeline is not allowed in search.
-
property
batch_number
(self)¶ Returns the number of batches which have been recommended so far.
-
property
default_max_batches
(self)¶ Returns the number of max batches AutoMLSearch should run by default.
-
abstract
next_batch
(self)[source]¶ Get the next batch of pipelines to evaluate.
- Returns
A list of instances of PipelineBase subclasses, ready to be trained and evaluated.
- Return type
list[PipelineBase]
-
property
pipeline_number
(self)¶ Returns the number of pipelines which have been recommended so far.
-
exception
evalml.automl.automl_algorithm.
AutoMLAlgorithmException
[source]¶ Exception raised when an error is encountered during the computation of the automl algorithm.
-
class
evalml.automl.automl_algorithm.
DefaultAlgorithm
(X, y, problem_type, sampler_name, tuner_class=None, random_seed=0, pipeline_params=None, custom_hyperparameters=None, n_jobs=- 1, text_in_ensembling=False, top_n=3, num_long_explore_pipelines=50, num_long_pipelines_per_batch=10, allow_long_running_models=False, verbose=False)[source]¶ An automl algorithm that consists of two modes: fast and long, where fast is a subset of long.
- Naive pipelines:
run baseline with default preprocessing pipeline
run naive linear model with default preprocessing pipeline
run basic RF pipeline with default preprocessing pipeline
- Naive pipelines with feature selection
subsequent pipelines will use the selected features with a SelectedColumns transformer
At this point we have a single pipeline candidate for preprocessing and feature selection
- Pipelines with preprocessing components:
scan rest of estimators (our current batch 1).
First ensembling run
Fast mode ends here. Begin long mode.
- Run top 3 estimators:
Generate 50 random parameter sets. Run all 150 in one batch
Second ensembling run
- Repeat these indefinitely until stopping criterion is met:
For each of the previous top 3 estimators, sample 10 parameters from the tuner. Run all 30 in one batch
Run ensembling
- Parameters
X (pd.DataFrame) – Training data.
y (pd.Series) – Target data.
problem_type (ProblemType) – Problem type associated with training data.
sampler_name (BaseSampler) – Sampler to use for preprocessing.
tuner_class (class) – A subclass of Tuner, to be used to find parameters for each pipeline. The default of None indicates the SKOptTuner will be used.
random_seed (int) – Seed for the random number generator. Defaults to 0.
pipeline_params (dict or None) – Pipeline-level parameters that should be passed to the proposed pipelines. Defaults to None.
custom_hyperparameters (dict or None) – Custom hyperparameter ranges specified for pipelines to iterate over. Defaults to None.
n_jobs (int or None) – Non-negative integer describing level of parallelism used for pipelines. Defaults to -1.
text_in_ensembling (boolean) – If True and ensembling is True, then n_jobs will be set to 1 to avoid downstream sklearn stacking issues related to nltk. Defaults to False.
top_n (int) – top n number of pipelines to use for long mode.
num_long_explore_pipelines (int) – number of pipelines to explore for each top n pipeline at the start of long mode.
num_long_pipelines_per_batch (int) – number of pipelines per batch for each top n pipeline through long mode.
allow_long_running_models (bool) – Whether or not to allow longer-running models for large multiclass problems. If False and no pipelines, component graphs, or model families are provided, AutoMLSearch will not use Elastic Net or XGBoost when there are more than 75 multiclass targets and will not use CatBoost when there are more than 150 multiclass targets. Defaults to False.
verbose (boolean) – Whether or not to display logging information regarding pipeline building. Defaults to False.
Methods
Register results from evaluating a pipeline. In batch number 2, the selected column names from the feature selector are taken to be used in a column selector. Information regarding the best pipeline is updated here as well.
Returns the number of batches which have been recommended so far.
Returns the number of max batches AutoMLSearch should run by default.
Get the next batch of pipelines to evaluate.
Returns the number of pipelines which have been recommended so far.
-
add_result
(self, score_to_minimize, pipeline, trained_pipeline_results)[source]¶ Register results from evaluating a pipeline. In batch number 2, the selected column names from the feature selector are taken to be used in a column selector. Information regarding the best pipeline is updated here as well.
- Parameters
score_to_minimize (float) – The score obtained by this pipeline on the primary objective, converted so that lower values indicate better pipelines.
pipeline (PipelineBase) – The trained pipeline object which was used to compute the score.
trained_pipeline_results (dict) – Results from training a pipeline.
-
property
batch_number
(self)¶ Returns the number of batches which have been recommended so far.
-
property
default_max_batches
(self)¶ Returns the number of max batches AutoMLSearch should run by default.
-
next_batch
(self)[source]¶ Get the next batch of pipelines to evaluate.
- Returns
a list of instances of PipelineBase subclasses, ready to be trained and evaluated.
- Return type
list(PipelineBase)
-
property
pipeline_number
(self)¶ Returns the number of pipelines which have been recommended so far.
-
class
evalml.automl.automl_algorithm.
IterativeAlgorithm
(X, y, problem_type, sampler_name=None, allowed_model_families=None, allowed_component_graphs=None, max_batches=None, max_iterations=None, tuner_class=None, random_seed=0, pipelines_per_batch=5, n_jobs=- 1, number_features=None, ensembling=False, text_in_ensembling=False, pipeline_params=None, custom_hyperparameters=None, _estimator_family_order=None, allow_long_running_models=False, verbose=False)[source]¶ An automl algorithm which first fits a base round of pipelines with default parameters, then does a round of parameter tuning on each pipeline in order of performance.
- Parameters
X (pd.DataFrame) – Training data.
y (pd.Series) – Target data.
problem_type (ProblemType) – Problem type associated with training data.
sampler_name (BaseSampler) – Sampler to use for preprocessing. Defaults to None.
allowed_model_families (list(str, ModelFamily)) – The model families to search. The default of None searches over all model families. Run evalml.pipelines.components.utils.allowed_model_families(“binary”) to see options. Change binary to multiclass or regression depending on the problem type. Note that if allowed_pipelines is provided, this parameter will be ignored.
allowed_component_graphs (dict) –
A dictionary of lists or ComponentGraphs indicating the component graphs allowed in the search. The format should follow { “Name_0”: [list_of_components], “Name_1”: [ComponentGraph(…)] }
The default of None indicates all pipeline component graphs for this problem type are allowed. Setting this field will cause allowed_model_families to be ignored.
e.g. allowed_component_graphs = { “My_Graph”: [“Imputer”, “One Hot Encoder”, “Random Forest Classifier”] }
max_batches (int) – The maximum number of batches to be evaluated. Used to determine ensembling. Defaults to None.
max_iterations (int) – The maximum number of iterations to be evaluated. Used to determine ensembling. Defaults to None.
tuner_class (class) – A subclass of Tuner, to be used to find parameters for each pipeline. The default of None indicates the SKOptTuner will be used.
random_seed (int) – Seed for the random number generator. Defaults to 0.
pipelines_per_batch (int) – The number of pipelines to be evaluated in each batch, after the first batch. Defaults to 5.
n_jobs (int or None) – Non-negative integer describing level of parallelism used for pipelines. Defaults to None.
number_features (int) – The number of columns in the input features. Defaults to None.
ensembling (boolean) – If True, runs ensembling in a separate batch after every allowed pipeline class has been iterated over. Defaults to False.
text_in_ensembling (boolean) – If True and ensembling is True, then n_jobs will be set to 1 to avoid downstream sklearn stacking issues related to nltk. Defaults to False.
pipeline_params (dict or None) – Pipeline-level parameters that should be passed to the proposed pipelines. Defaults to None.
custom_hyperparameters (dict or None) – Custom hyperparameter ranges specified for pipelines to iterate over. Defaults to None.
_estimator_family_order (list(ModelFamily) or None) – specify the sort order for the first batch. Defaults to None, which uses _ESTIMATOR_FAMILY_ORDER.
allow_long_running_models (bool) – Whether or not to allow longer-running models for large multiclass problems. If False and no pipelines, component graphs, or model families are provided, AutoMLSearch will not use Elastic Net or XGBoost when there are more than 75 multiclass targets and will not use CatBoost when there are more than 150 multiclass targets. Defaults to False.
verbose (boolean) – Whether or not to display logging information regarding pipeline building. Defaults to False.
Methods
Register results from evaluating a pipeline.
Returns the number of batches which have been recommended so far.
Returns the number of max batches AutoMLSearch should run by default.
Get the next batch of pipelines to evaluate.
Returns the number of pipelines which have been recommended so far.
-
add_result
(self, score_to_minimize, pipeline, trained_pipeline_results)[source]¶ Register results from evaluating a pipeline.
- Parameters
score_to_minimize (float) – The score obtained by this pipeline on the primary objective, converted so that lower values indicate better pipelines.
pipeline (PipelineBase) – The trained pipeline object which was used to compute the score.
trained_pipeline_results (dict) – Results from training a pipeline.
- Raises
ValueError – If default parameters are not in the acceptable hyperparameter ranges.
-
property
batch_number
(self)¶ Returns the number of batches which have been recommended so far.
-
property
default_max_batches
(self)¶ Returns the number of max batches AutoMLSearch should run by default.
-
next_batch
(self)[source]¶ Get the next batch of pipelines to evaluate.
- Returns
A list of instances of PipelineBase subclasses, ready to be trained and evaluated.
- Return type
list[PipelineBase]
- Raises
AutoMLAlgorithmException – If no results were reported from the first batch.
-
property
pipeline_number
(self)¶ Returns the number of pipelines which have been recommended so far.