Automated Machine Learning (AutoML) Search¶
Background¶
Machine Learning¶
Machine learning (ML) is the process of constructing a mathematical model of a system based on a sample dataset collected from that system.
One of the main goals of training an ML model is to teach the model to separate the signal present in the data from the noise inherent in system and in the data collection process. If this is done effectively, the model can then be used to make accurate predictions about the system when presented with new, similar data. Additionally, introspecting on an ML model can reveal key information about the system being modeled, such as which inputs and transformations of the inputs are most useful to the ML model for learning the signal in the data, and are therefore the most predictive.
There are a variety of ML problem types. Supervised learning describes the case where the collected data contains an output value to be modeled and a set of inputs with which to train the model. EvalML focuses on training supervised learning models.
EvalML supports three common supervised ML problem types. The first is regression, where the target value to model is a continuous numeric value. Next are binary and multiclass classification, where the target value to model consists of two or more discrete values or categories. The choice of which supervised ML problem type is most appropriate depends on domain expertise and on how the model will be evaluated and used.
EvalML is currently building support for supervised time series problems: time series regression, time series binary classification, and time series multiclass classification. While we’ve added some features to tackle these kinds of problems, our functionality is still being actively developed so please be mindful of that before using it.
AutoML and Search¶
AutoML is the process of automating the construction, training and evaluation of ML models. Given a data and some configuration, AutoML searches for the most effective and accurate ML model or models to fit the dataset. During the search, AutoML will explore different combinations of model type, model parameters and model architecture.
An effective AutoML solution offers several advantages over constructing and tuning ML models by hand. AutoML can assist with many of the difficult aspects of ML, such as avoiding overfitting and underfitting, imbalanced data, detecting data leakage and other potential issues with the problem setup, and automatically applying best-practice data cleaning, feature engineering, feature selection and various modeling techniques. AutoML can also leverage search algorithms to optimally sweep the hyperparameter search space, resulting in model performance which would be difficult to achieve by manual training.
AutoML in EvalML¶
EvalML supports all of the above and more.
In its simplest usage, the AutoML search interface requires only the input data, the target data and a problem_type
specifying what kind of supervised ML problem to model.
** Graphing methods, like AutoMLSearch, on Jupyter Notebook and Jupyter Lab require ipywidgets to be installed.
** If graphing on Jupyter Lab, jupyterlab-plotly required. To download this, make sure you have npm installed.
[1]:
import evalml
from evalml.utils import infer_feature_types
X, y = evalml.demos.load_fraud(n_rows=250)
Number of Features
Boolean 1
Categorical 6
Numeric 5
Number of training examples: 250
Targets
False 88.40%
True 11.60%
Name: fraud, dtype: object
To provide data to EvalML, it is recommended that you initialize a Woodwork accessor on your data. This allows you to easily control how EvalML will treat each of your features before training a model.
EvalML also accepts pandas
input, and will run type inference on top of the input pandas
data. If you’d like to change the types inferred by EvalML, you can use the infer_feature_types
utility method, which takes pandas or numpy input and converts it to a Woodwork data structure. The feature_types
parameter can be used to specify what types specific columns should be.
Feature types such as Natural Language
must be specified in this way, otherwise Woodwork will infer it as Unknown
type and drop it during the AutoMLSearch.
In the example below, we reformat a couple features to make them easily consumable by the model, and then specify that the provider, which would have otherwise been inferred as a column with natural language, is a categorical column.
[2]:
X.ww['expiration_date'] = X['expiration_date'].apply(lambda x: '20{}-01-{}'.format(x.split("/")[1], x.split("/")[0]))
X = infer_feature_types(X, feature_types= {'store_id': 'categorical',
'expiration_date': 'datetime',
'lat': 'categorical',
'lng': 'categorical',
'provider': 'categorical'})
In order to validate the results of the pipeline creation and optimization process, we will save some of our data as a holdout set.
[3]:
X_train, X_holdout, y_train, y_holdout = evalml.preprocessing.split_data(X, y, problem_type='binary', test_size=.2)
Data Checks¶
Before calling AutoMLSearch.search
, we should run some sanity checks on our data to ensure that the input data being passed will not run into some common issues before running a potentially time-consuming search. EvalML has various data checks that makes this easy. Each data check will return a collection of warnings and errors if it detects potential issues with the input data. This allows users to inspect their data to avoid confusing errors that may arise during the search process. You
can learn about each of the data checks available through our data checks guide
Here, we will run the DefaultDataChecks
class, which contains a series of data checks that are generally useful.
[4]:
from evalml.data_checks import DefaultDataChecks
data_checks = DefaultDataChecks("binary", "log loss binary")
data_checks.validate(X_train, y_train)
[4]:
{'warnings': [], 'errors': [], 'actions': []}
Since there were no warnings or errors returned, we can safely continue with the search process.
[5]:
automl = evalml.automl.AutoMLSearch(X_train=X_train, y_train=y_train, problem_type='binary')
automl.search()
Using default limit of max_batches=1.
Generating pipelines to search over...
8 pipelines ready for search.
*****************************
* Beginning pipeline search *
*****************************
Optimizing for Log Loss Binary.
Lower score is better.
Using SequentialEngine to train and score pipelines.
Searching up to 1 batches for a total of 9 pipelines.
Allowed model families: linear_model, xgboost, decision_tree, extra_trees, lightgbm, catboost, random_forest
Evaluating Baseline Pipeline: Mode Baseline Binary Classification Pipeline
Mode Baseline Binary Classification Pipeline:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 3.970
*****************************
* Evaluating Batch Number 1 *
*****************************
Elastic Net Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.512
Decision Tree Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 2.957
High coefficient of variation (cv >= 0.2) within cross validation scores.
Decision Tree Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler may not perform as estimated on unseen data.
Random Forest Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.286
LightGBM Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.309
High coefficient of variation (cv >= 0.2) within cross validation scores.
LightGBM Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler may not perform as estimated on unseen data.
Logistic Regression Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.552
/home/docs/checkouts/readthedocs.org/user_builds/feature-labs-inc-evalml/envs/v0.30.2/lib/python3.8/site-packages/xgboost/sklearn.py:1146: UserWarning:
The use of label encoder in XGBClassifier is deprecated and will be removed in a future release. To remove this warning, do the following: 1) Pass option use_label_encoder=False when constructing XGBClassifier object; and 2) Encode your labels (y) as integers starting with 0, i.e. 0, 1, 2, ..., [num_class - 1].
[20:22:48] WARNING: ../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.
/home/docs/checkouts/readthedocs.org/user_builds/feature-labs-inc-evalml/envs/v0.30.2/lib/python3.8/site-packages/xgboost/sklearn.py:1146: UserWarning:
The use of label encoder in XGBClassifier is deprecated and will be removed in a future release. To remove this warning, do the following: 1) Pass option use_label_encoder=False when constructing XGBClassifier object; and 2) Encode your labels (y) as integers starting with 0, i.e. 0, 1, 2, ..., [num_class - 1].
[20:22:49] WARNING: ../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.
/home/docs/checkouts/readthedocs.org/user_builds/feature-labs-inc-evalml/envs/v0.30.2/lib/python3.8/site-packages/xgboost/sklearn.py:1146: UserWarning:
The use of label encoder in XGBClassifier is deprecated and will be removed in a future release. To remove this warning, do the following: 1) Pass option use_label_encoder=False when constructing XGBClassifier object; and 2) Encode your labels (y) as integers starting with 0, i.e. 0, 1, 2, ..., [num_class - 1].
[20:22:50] WARNING: ../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.
XGBoost Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.279
High coefficient of variation (cv >= 0.2) within cross validation scores.
XGBoost Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler may not perform as estimated on unseen data.
Extra Trees Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.338
CatBoost Classifier w/ Imputer + DateTime Featurization Component + SMOTENC Oversampler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.602
Search finished after 00:21
/home/docs/checkouts/readthedocs.org/user_builds/feature-labs-inc-evalml/envs/v0.30.2/lib/python3.8/site-packages/xgboost/sklearn.py:1146: UserWarning:
The use of label encoder in XGBClassifier is deprecated and will be removed in a future release. To remove this warning, do the following: 1) Pass option use_label_encoder=False when constructing XGBClassifier object; and 2) Encode your labels (y) as integers starting with 0, i.e. 0, 1, 2, ..., [num_class - 1].
[20:22:55] WARNING: ../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.
Best pipeline: XGBoost Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler
Best pipeline Log Loss Binary: 0.278707
The AutoML search will log its progress, reporting each pipeline and parameter set evaluated during the search.
There are a number of mechanisms to control the AutoML search time. One way is to set the max_batches
parameter which controls the maximum number of rounds of AutoML to evaluate, where each round may train and score a variable number of pipelines. Another way is to set the max_iterations
parameter which controls the maximum number of candidate models to be evaluated during AutoML. By default, AutoML will search for a single batch. The first pipeline to be evaluated will always be a
baseline model representing a trivial solution.
The AutoML interface supports a variety of other parameters. For a comprehensive list, please refer to the API reference.
We also provide a standalone search method which does all of the above in a single line, and returns the AutoMLSearch
instance and data check results. If there were data check errors, AutoML will not be run and no AutoMLSearch
instance will be returned.
Detecting Problem Type¶
EvalML includes a simple method, detect_problem_type
, to help determine the problem type given the target data.
This function can return the predicted problem type as a ProblemType enum, choosing from ProblemType.BINARY, ProblemType.MULTICLASS, and ProblemType.REGRESSION. If the target data is invalid (for instance when there is only 1 unique label), the function will throw an error instead.
[6]:
import pandas as pd
from evalml.problem_types import detect_problem_type
y_binary = pd.Series([0, 1, 1, 0, 1, 1])
detect_problem_type(y_binary)
[6]:
<ProblemTypes.BINARY: 'binary'>
Objective parameter¶
AutoMLSearch takes in an objective
parameter to determine which objective
to optimize for. By default, this parameter is set to auto
, which allows AutoML to choose LogLossBinary
for binary classification problems, LogLossMulticlass
for multiclass classification problems, and R2
for regression problems.
It should be noted that the objective
parameter is only used in ranking and helping choose the pipelines to iterate over, but is not used to optimize each individual pipeline during fit-time.
To get the default objective for each problem type, you can use the get_default_primary_search_objective
function.
[7]:
from evalml.automl import get_default_primary_search_objective
binary_objective = get_default_primary_search_objective("binary")
multiclass_objective = get_default_primary_search_objective("multiclass")
regression_objective = get_default_primary_search_objective("regression")
print(binary_objective.name)
print(multiclass_objective.name)
print(regression_objective.name)
Log Loss Binary
Log Loss Multiclass
R2
Using custom pipelines¶
EvalML’s AutoML algorithm generates a set of pipelines to search with. To provide a custom set instead, set allowed_component_graphs to a dictionary of custom component graphs. AutoMLSearch
will use these to generate Pipeline
instances. Note: this will prevent AutoML from generating other pipelines to search over.
[8]:
from evalml.pipelines import MulticlassClassificationPipeline
automl_custom = evalml.automl.AutoMLSearch(X_train=X_train,
y_train=y_train,
problem_type='multiclass',
allowed_component_graphs={"My_pipeline": ['Simple Imputer', 'Random Forest Classifier'],
"My_other_pipeline": ['One Hot Encoder', 'Random Forest Classifier']})
Using default limit of max_batches=1.
2 pipelines ready for search.
/home/docs/checkouts/readthedocs.org/user_builds/feature-labs-inc-evalml/envs/v0.30.2/lib/python3.8/site-packages/evalml/automl/automl_search.py:676: ParameterNotUsedWarning:
Parameters for components {'SMOTENC Oversampler'} will not be used to instantiate the pipeline since they don't appear in the pipeline
Stopping the search early¶
To stop the search early, hit Ctrl-C
. This will bring up a prompt asking for confirmation. Responding with y
will immediately stop the search. Responding with n
will continue the search.
Callback functions¶
AutoMLSearch
supports several callback functions, which can be specified as parameters when initializing an AutoMLSearch
object. They are:
start_iteration_callback
add_result_callback
error_callback
Start Iteration Callback¶
Users can set start_iteration_callback
to set what function is called before each pipeline training iteration. This callback function must take three positional parameters: the pipeline class, the pipeline parameters, and the AutoMLSearch
object.
[9]:
## start_iteration_callback example function
def start_iteration_callback_example(pipeline_class, pipeline_params, automl_obj):
print ("Training pipeline with the following parameters:", pipeline_params)
Add Result Callback¶
Users can set add_result_callback
to set what function is called after each pipeline training iteration. This callback function must take three positional parameters: a dictionary containing the training results for the new pipeline, an untrained_pipeline containing the parameters used during training, and the AutoMLSearch
object.
[10]:
## add_result_callback example function
def add_result_callback_example(pipeline_results_dict, untrained_pipeline, automl_obj):
print ("Results for trained pipeline with the following parameters:", pipeline_results_dict)
Error Callback¶
Users can set the error_callback
to set what function called when search()
errors and raises an Exception
. This callback function takes three positional parameters: the Exception raised
, the traceback, and the AutoMLSearch object
. This callback function must also accept kwargs
, so AutoMLSearch
is able to pass along other parameters used by default.
Evalml defines several error callback functions, which can be found under evalml.automl.callbacks
. They are:
silent_error_callback
raise_error_callback
log_and_save_error_callback
raise_and_save_error_callback
log_error_callback
(default used whenerror_callback
is None)
[11]:
# error_callback example; this is implemented in the evalml library
def raise_error_callback(exception, traceback, automl, **kwargs):
"""Raises the exception thrown by the AutoMLSearch object. Also logs the exception as an error."""
logger.error(f'AutoMLSearch raised a fatal exception: {str(exception)}')
logger.error("\n".join(traceback))
raise exception
View Rankings¶
A summary of all the pipelines built can be returned as a pandas DataFrame which is sorted by score. The score column contains the average score across all cross-validation folds while the validation_score column is computed from the first cross-validation fold.
[12]:
automl.rankings
[12]:
id | pipeline_name | search_order | mean_cv_score | standard_deviation_cv_score | validation_score | percent_better_than_baseline | high_variance_cv | parameters | |
---|---|---|---|---|---|---|---|---|---|
0 | 6 | XGBoost Classifier w/ Imputer + DateTime Featu... | 6 | 0.278707 | 0.190725 | 0.202638 | 92.980409 | True | {'Imputer': {'categorical_impute_strategy': 'm... |
1 | 3 | Random Forest Classifier w/ Imputer + DateTime... | 3 | 0.285613 | 0.041116 | 0.263695 | 92.806475 | False | {'Imputer': {'categorical_impute_strategy': 'm... |
2 | 4 | LightGBM Classifier w/ Imputer + DateTime Feat... | 4 | 0.308636 | 0.203878 | 0.234947 | 92.226623 | True | {'Imputer': {'categorical_impute_strategy': 'm... |
3 | 7 | Extra Trees Classifier w/ Imputer + DateTime F... | 7 | 0.338286 | 0.009381 | 0.329015 | 91.479857 | False | {'Imputer': {'categorical_impute_strategy': 'm... |
4 | 1 | Elastic Net Classifier w/ Imputer + DateTime F... | 1 | 0.511808 | 0.074992 | 0.590517 | 87.109474 | False | {'Imputer': {'categorical_impute_strategy': 'm... |
5 | 5 | Logistic Regression Classifier w/ Imputer + Da... | 5 | 0.551960 | 0.082695 | 0.628646 | 86.098206 | False | {'Imputer': {'categorical_impute_strategy': 'm... |
6 | 8 | CatBoost Classifier w/ Imputer + DateTime Feat... | 8 | 0.601819 | 0.007246 | 0.593693 | 84.842444 | False | {'Imputer': {'categorical_impute_strategy': 'm... |
7 | 2 | Decision Tree Classifier w/ Imputer + DateTime... | 2 | 2.956956 | 3.084439 | 0.651557 | 25.525413 | True | {'Imputer': {'categorical_impute_strategy': 'm... |
8 | 0 | Mode Baseline Binary Classification Pipeline | 0 | 3.970423 | 0.266060 | 4.124033 | 0.000000 | False | {'Baseline Classifier': {'strategy': 'mode'}} |
Describe Pipeline¶
Each pipeline is given an id
. We can get more information about any particular pipeline using that id
. Here, we will get more information about the pipeline with id = 1
.
[13]:
automl.describe_pipeline(1)
**********************************************************************************************************************************
* Elastic Net Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler *
**********************************************************************************************************************************
Problem Type: binary
Model Family: Linear
Pipeline Steps
==============
1. Imputer
* categorical_impute_strategy : most_frequent
* numeric_impute_strategy : mean
* categorical_fill_value : None
* numeric_fill_value : None
2. DateTime Featurization Component
* features_to_extract : ['year', 'month', 'day_of_week', 'hour']
* encode_as_categories : False
* date_index : None
3. One Hot Encoder
* top_n : 10
* features_to_encode : None
* categories : None
* drop : if_binary
* handle_unknown : ignore
* handle_missing : error
4. SMOTENC Oversampler
* sampling_ratio : 0.25
* k_neighbors_default : 5
* n_jobs : -1
* sampling_ratio_dict : None
* categorical_features : [3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
* k_neighbors : 5
5. Standard Scaler
6. Elastic Net Classifier
* penalty : elasticnet
* C : 1.0
* l1_ratio : 0.15
* n_jobs : -1
* multi_class : auto
* solver : saga
Training
========
Training for binary problems.
Total training time (including CV): 2.7 seconds
Cross Validation
----------------
Log Loss Binary MCC Binary Gini AUC Precision F1 Balanced Accuracy Binary Accuracy Binary # Training # Validation
0 0.591 0.175 0.195 0.597 0.286 0.267 0.583 0.836 133 67
1 0.441 0.296 0.419 0.710 0.500 0.333 0.608 0.881 133 67
2 0.504 0.035 0.259 0.630 0.120 0.188 0.528 0.606 134 66
mean 0.512 0.169 0.291 0.646 0.302 0.263 0.573 0.774 - -
std 0.075 0.130 0.116 0.058 0.191 0.073 0.041 0.147 - -
coef of var 0.147 0.772 0.397 0.090 0.631 0.278 0.072 0.190 - -
Get Pipeline¶
We can get the object of any pipeline via their id
as well:
[14]:
pipeline = automl.get_pipeline(1)
print(pipeline.name)
print(pipeline.parameters)
Elastic Net Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler
{'Imputer': {'categorical_impute_strategy': 'most_frequent', 'numeric_impute_strategy': 'mean', 'categorical_fill_value': None, 'numeric_fill_value': None}, 'DateTime Featurization Component': {'features_to_extract': ['year', 'month', 'day_of_week', 'hour'], 'encode_as_categories': False, 'date_index': None}, 'One Hot Encoder': {'top_n': 10, 'features_to_encode': None, 'categories': None, 'drop': 'if_binary', 'handle_unknown': 'ignore', 'handle_missing': 'error'}, 'SMOTENC Oversampler': {'sampling_ratio': 0.25, 'k_neighbors_default': 5, 'n_jobs': -1, 'sampling_ratio_dict': None, 'categorical_features': [3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59], 'k_neighbors': 5}, 'Elastic Net Classifier': {'penalty': 'elasticnet', 'C': 1.0, 'l1_ratio': 0.15, 'n_jobs': -1, 'multi_class': 'auto', 'solver': 'saga'}}
Get best pipeline¶
If you specifically want to get the best pipeline, there is a convenient accessor for that. The pipeline returned is already fitted on the input X, y data that we passed to AutoMLSearch. To turn off this default behavior, set train_best_pipeline=False
when initializing AutoMLSearch.
[15]:
best_pipeline = automl.best_pipeline
print(best_pipeline.name)
print(best_pipeline.parameters)
best_pipeline.predict(X_train)
XGBoost Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler
{'Imputer': {'categorical_impute_strategy': 'most_frequent', 'numeric_impute_strategy': 'mean', 'categorical_fill_value': None, 'numeric_fill_value': None}, 'DateTime Featurization Component': {'features_to_extract': ['year', 'month', 'day_of_week', 'hour'], 'encode_as_categories': False, 'date_index': None}, 'One Hot Encoder': {'top_n': 10, 'features_to_encode': None, 'categories': None, 'drop': 'if_binary', 'handle_unknown': 'ignore', 'handle_missing': 'error'}, 'SMOTENC Oversampler': {'sampling_ratio': 0.25, 'k_neighbors_default': 5, 'n_jobs': -1, 'sampling_ratio_dict': None, 'categorical_features': [3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59], 'k_neighbors': 5}, 'XGBoost Classifier': {'eta': 0.1, 'max_depth': 6, 'min_child_weight': 1, 'n_estimators': 100, 'n_jobs': -1}}
[15]:
0 False
1 False
2 False
3 True
4 False
...
195 False
196 False
197 False
198 False
199 False
Name: fraud, Length: 200, dtype: bool
Training and Scoring Multiple Pipelines using AutoMLSearch¶
AutoMLSearch will automatically fit the best pipeline on the entire training data. It also provides an easy API for training and scoring other pipelines.
If you’d like to train one or more pipelines on the entire training data, you can use the train_pipelines
method
Similarly, if you’d like to score one or more pipelines on a particular dataset, you can use the train_pipelines
method
[16]:
trained_pipelines = automl.train_pipelines([automl.get_pipeline(i) for i in [0, 1, 2]])
trained_pipelines
[16]:
{'Mode Baseline Binary Classification Pipeline': pipeline = BinaryClassificationPipeline(component_graph={'Baseline Classifier': ['Baseline Classifier', 'X', 'y']}, parameters={'Baseline Classifier':{'strategy': 'mode'}}, custom_name='Mode Baseline Binary Classification Pipeline', random_seed=0),
'Elastic Net Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler': pipeline = BinaryClassificationPipeline(component_graph={'Imputer': ['Imputer', 'X', 'y'], 'DateTime Featurization Component': ['DateTime Featurization Component', 'Imputer.x', 'y'], 'One Hot Encoder': ['One Hot Encoder', 'DateTime Featurization Component.x', 'y'], 'SMOTENC Oversampler': ['SMOTENC Oversampler', 'One Hot Encoder.x', 'y'], 'Standard Scaler': ['Standard Scaler', 'SMOTENC Oversampler.x', 'SMOTENC Oversampler.y'], 'Elastic Net Classifier': ['Elastic Net Classifier', 'Standard Scaler.x', 'SMOTENC Oversampler.y']}, parameters={'Imputer':{'categorical_impute_strategy': 'most_frequent', 'numeric_impute_strategy': 'mean', 'categorical_fill_value': None, 'numeric_fill_value': None}, 'DateTime Featurization Component':{'features_to_extract': ['year', 'month', 'day_of_week', 'hour'], 'encode_as_categories': False, 'date_index': None}, 'One Hot Encoder':{'top_n': 10, 'features_to_encode': None, 'categories': None, 'drop': 'if_binary', 'handle_unknown': 'ignore', 'handle_missing': 'error'}, 'SMOTENC Oversampler':{'sampling_ratio': 0.25, 'k_neighbors_default': 5, 'n_jobs': -1, 'sampling_ratio_dict': None, 'categorical_features': [3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59], 'k_neighbors': 5}, 'Elastic Net Classifier':{'penalty': 'elasticnet', 'C': 1.0, 'l1_ratio': 0.15, 'n_jobs': -1, 'multi_class': 'auto', 'solver': 'saga'}}, random_seed=0),
'Decision Tree Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler': pipeline = BinaryClassificationPipeline(component_graph={'Imputer': ['Imputer', 'X', 'y'], 'DateTime Featurization Component': ['DateTime Featurization Component', 'Imputer.x', 'y'], 'One Hot Encoder': ['One Hot Encoder', 'DateTime Featurization Component.x', 'y'], 'SMOTENC Oversampler': ['SMOTENC Oversampler', 'One Hot Encoder.x', 'y'], 'Decision Tree Classifier': ['Decision Tree Classifier', 'SMOTENC Oversampler.x', 'SMOTENC Oversampler.y']}, parameters={'Imputer':{'categorical_impute_strategy': 'most_frequent', 'numeric_impute_strategy': 'mean', 'categorical_fill_value': None, 'numeric_fill_value': None}, 'DateTime Featurization Component':{'features_to_extract': ['year', 'month', 'day_of_week', 'hour'], 'encode_as_categories': False, 'date_index': None}, 'One Hot Encoder':{'top_n': 10, 'features_to_encode': None, 'categories': None, 'drop': 'if_binary', 'handle_unknown': 'ignore', 'handle_missing': 'error'}, 'SMOTENC Oversampler':{'sampling_ratio': 0.25, 'k_neighbors_default': 5, 'n_jobs': -1, 'sampling_ratio_dict': None, 'categorical_features': [3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59], 'k_neighbors': 5}, 'Decision Tree Classifier':{'criterion': 'gini', 'max_features': 'auto', 'max_depth': 6, 'min_samples_split': 2, 'min_weight_fraction_leaf': 0.0}}, random_seed=0)}
[17]:
pipeline_holdout_scores = automl.score_pipelines([trained_pipelines[name] for name in trained_pipelines.keys()],
X_holdout,
y_holdout,
['Accuracy Binary', 'F1', 'AUC'])
pipeline_holdout_scores
[17]:
{'Mode Baseline Binary Classification Pipeline': OrderedDict([('Accuracy Binary',
0.88),
('F1', 0.0),
('AUC', 0.5)]),
'Elastic Net Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler': OrderedDict([('Accuracy Binary',
0.66),
('F1', 0.19047619047619044),
('AUC', 0.5265151515151515)]),
'Decision Tree Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler': OrderedDict([('Accuracy Binary',
0.92),
('F1', 0.6),
('AUC', 0.7234848484848486)])}
Saving AutoMLSearch and pipelines from AutoMLSearch¶
There are two ways to save results from AutoMLSearch.
You can save the AutoMLSearch object itself, calling
.save(<filepath>)
to do so. This will allow you to save the AutoMLSearch state and reload all pipelines from this.If you want to save a pipeline from AutoMLSearch for future use, pipeline classes themselves have a
.save(<filepath>)
method.
[18]:
# saving the entire automl search
automl.save("automl.cloudpickle")
automl2 = evalml.automl.AutoMLSearch.load("automl.cloudpickle")
# saving the best pipeline using .save()
best_pipeline.save("pipeline.cloudpickle")
best_pipeline_copy = evalml.pipelines.PipelineBase.load("pipeline.cloudpickle")
Limiting the AutoML Search Space¶
The AutoML search algorithm first trains each component in the pipeline with their default values. After the first iteration, it then tweaks the parameters of these components using the pre-defined hyperparameter ranges that these components have. To limit the search over certain hyperparameter ranges, you can specify a custom_hyperparameters
argument with your AutoMLSearch
parameters. These parameters will limit the hyperparameter search space.
Hyperparameter ranges can be found through the API reference for each component. Parameter arguments must be specified as dictionaries, but the associated values can be single values or skopt.space
Real, Integer, Categorical values.
If however you’d like to specify certain values for the initial batch of the AutoML search algorithm, you can use the pipeline_parameters
argument. This will set the initial batch’s component parameters to the values passed by this argument.
[19]:
from evalml import AutoMLSearch
from evalml.demos import load_fraud
from skopt.space import Categorical
from evalml.model_family import ModelFamily
import woodwork as ww
X, y = load_fraud(n_rows=1000)
# example of setting parameter to just one value
custom_hyperparameters = {'Imputer': {
'numeric_impute_strategy': 'mean'
}}
# limit the numeric impute strategy to include only `median` and `most_frequent`
# `mean` is the default value for this argument, but it doesn't need to be included in the specified hyperparameter range for this to work
custom_hyperparameters = {'Imputer': {
'numeric_impute_strategy': Categorical(['median', 'most_frequent'])
}}
# set the initial batch numeric impute strategy strategy to 'median'
pipeline_parameters = {'Imputer': {
'numeric_impute_strategy': 'median'
}}
# using this custom hyperparameter means that our Imputer components in these pipelines will only search through
# 'median' and 'most_frequent' strategies for 'numeric_impute_strategy', and the initial batch parameter will be
# set to 'median'
automl_constrained = AutoMLSearch(X_train=X, y_train=y, problem_type='binary', pipeline_parameters=pipeline_parameters,
custom_hyperparameters=custom_hyperparameters)
Number of Features
Boolean 1
Categorical 6
Numeric 5
Number of training examples: 1000
Targets
False 85.90%
True 14.10%
Name: fraud, dtype: object
Using default limit of max_batches=1.
Generating pipelines to search over...
8 pipelines ready for search.
Imbalanced Data¶
The AutoML search algorithm now has functionality to handle imbalanced data during classification! AutoMLSearch now provides two additional parameters, sampler_method
and sampler_balanced_ratio
, that allow you to let AutoMLSearch know whether to sample imbalanced data, and how to do so. sampler_method
takes in either Undersampler
, Oversampler
, auto
, or None as the sampler to use, and sampler_balanced_ratio
specifies the minority/majority
ratio that you want to
sample to. Details on the Undersampler and Oversampler components can be found in the documentation.
This can be used for imbalanced datasets, like the fraud dataset, which has a ‘minority:majority’ ratio of < 0.2.
[20]:
automl_auto = AutoMLSearch(X_train=X, y_train=y, problem_type='binary')
automl_auto.allowed_pipelines[-1]
Using default limit of max_batches=1.
Generating pipelines to search over...
8 pipelines ready for search.
[20]:
pipeline = BinaryClassificationPipeline(component_graph={'Imputer': ['Imputer', 'X', 'y'], 'DateTime Featurization Component': ['DateTime Featurization Component', 'Imputer.x', 'y'], 'One Hot Encoder': ['One Hot Encoder', 'DateTime Featurization Component.x', 'y'], 'SMOTENC Oversampler': ['SMOTENC Oversampler', 'One Hot Encoder.x', 'y'], 'Standard Scaler': ['Standard Scaler', 'SMOTENC Oversampler.x', 'SMOTENC Oversampler.y'], 'Logistic Regression Classifier': ['Logistic Regression Classifier', 'Standard Scaler.x', 'SMOTENC Oversampler.y']}, parameters={'Imputer':{'categorical_impute_strategy': 'most_frequent', 'numeric_impute_strategy': 'mean', 'categorical_fill_value': None, 'numeric_fill_value': None}, 'DateTime Featurization Component':{'features_to_extract': ['year', 'month', 'day_of_week', 'hour'], 'encode_as_categories': False, 'date_index': None}, 'One Hot Encoder':{'top_n': 10, 'features_to_encode': None, 'categories': None, 'drop': 'if_binary', 'handle_unknown': 'ignore', 'handle_missing': 'error'}, 'SMOTENC Oversampler':{'sampling_ratio': 0.25, 'k_neighbors_default': 5, 'n_jobs': -1, 'sampling_ratio_dict': None}, 'Logistic Regression Classifier':{'penalty': 'l2', 'C': 1.0, 'n_jobs': -1, 'multi_class': 'auto', 'solver': 'lbfgs'}}, random_seed=0)
The SMOTENC Oversampler is chosen as the default sampling component here, since the sampler_balanced_ratio = 0.25
. If you specified a lower ratio, for instance sampler_balanced_ratio = 0.1
, then there would be no sampling component added here. This is because if a ratio of 0.1 would be considered balanced, then a ratio of 0.2 would also be balanced.
[21]:
automl_auto_ratio = AutoMLSearch(X_train=X, y_train=y, problem_type='binary', sampler_balanced_ratio=0.1)
automl_auto_ratio.allowed_pipelines[-1]
Using default limit of max_batches=1.
Generating pipelines to search over...
8 pipelines ready for search.
[21]:
pipeline = BinaryClassificationPipeline(component_graph={'Imputer': ['Imputer', 'X', 'y'], 'DateTime Featurization Component': ['DateTime Featurization Component', 'Imputer.x', 'y'], 'One Hot Encoder': ['One Hot Encoder', 'DateTime Featurization Component.x', 'y'], 'Standard Scaler': ['Standard Scaler', 'One Hot Encoder.x', 'y'], 'Logistic Regression Classifier': ['Logistic Regression Classifier', 'Standard Scaler.x', 'y']}, parameters={'Imputer':{'categorical_impute_strategy': 'most_frequent', 'numeric_impute_strategy': 'mean', 'categorical_fill_value': None, 'numeric_fill_value': None}, 'DateTime Featurization Component':{'features_to_extract': ['year', 'month', 'day_of_week', 'hour'], 'encode_as_categories': False, 'date_index': None}, 'One Hot Encoder':{'top_n': 10, 'features_to_encode': None, 'categories': None, 'drop': 'if_binary', 'handle_unknown': 'ignore', 'handle_missing': 'error'}, 'Logistic Regression Classifier':{'penalty': 'l2', 'C': 1.0, 'n_jobs': -1, 'multi_class': 'auto', 'solver': 'lbfgs'}}, random_seed=0)
Additionally, you can add more fine-grained sampling ratios by passing in a sampling_ratio_dict
in pipeline parameters. For this dictionary, AutoMLSearch expects the keys to be int values from 0 to n-1
for the classes, and the values would be the sampler_balanced__ratio
associated with each target. This dictionary would override the AutoML argument sampler_balanced_ratio
. Below, you can see the scenario for Oversampler component on this dataset. Note that the logic for
Undersamplers is included in the commented section.
[22]:
# In this case, the majority class is the negative class
# for the oversampler, we don't want to oversample this class, so class 0 (majority) will have a ratio of 1 to itself
# for the minority class 1, we want to oversample it to have a minority/majority ratio of 0.5, which means we want minority to have 1/2 the samples as the minority
sampler_ratio_dict = {0: 1, 1: 0.5}
pipeline_parameters = {"SMOTENC Oversampler": {"sampler_balanced_ratio": sampler_ratio_dict}}
automl_auto_ratio_dict = AutoMLSearch(X_train=X, y_train=y, problem_type='binary', pipeline_parameters=pipeline_parameters)
automl_auto_ratio_dict.allowed_pipelines[-1]
# Undersampler case
# we don't want to undersample this class, so class 1 (minority) will have a ratio of 1 to itself
# for the majority class 0, we want to undersample it to have a minority/majority ratio of 0.5, which means we want majority to have 2x the samples as the minority
# sampler_ratio_dict = {0: 0.5, 1: 1}
# pipeline_parameters = {"SMOTENC Oversampler": {"sampler_balanced_ratio": sampler_ratio_dict}}
# automl_auto_ratio_dict = AutoMLSearch(X_train=X, y_train=y, problem_type='binary', pipeline_parameters=pipeline_parameters)
Using default limit of max_batches=1.
Generating pipelines to search over...
8 pipelines ready for search.
[22]:
pipeline = BinaryClassificationPipeline(component_graph={'Imputer': ['Imputer', 'X', 'y'], 'DateTime Featurization Component': ['DateTime Featurization Component', 'Imputer.x', 'y'], 'One Hot Encoder': ['One Hot Encoder', 'DateTime Featurization Component.x', 'y'], 'SMOTENC Oversampler': ['SMOTENC Oversampler', 'One Hot Encoder.x', 'y'], 'Standard Scaler': ['Standard Scaler', 'SMOTENC Oversampler.x', 'SMOTENC Oversampler.y'], 'Logistic Regression Classifier': ['Logistic Regression Classifier', 'Standard Scaler.x', 'SMOTENC Oversampler.y']}, parameters={'Imputer':{'categorical_impute_strategy': 'most_frequent', 'numeric_impute_strategy': 'mean', 'categorical_fill_value': None, 'numeric_fill_value': None}, 'DateTime Featurization Component':{'features_to_extract': ['year', 'month', 'day_of_week', 'hour'], 'encode_as_categories': False, 'date_index': None}, 'One Hot Encoder':{'top_n': 10, 'features_to_encode': None, 'categories': None, 'drop': 'if_binary', 'handle_unknown': 'ignore', 'handle_missing': 'error'}, 'SMOTENC Oversampler':{'sampling_ratio': 0.25, 'k_neighbors_default': 5, 'n_jobs': -1, 'sampling_ratio_dict': None, 'sampler_balanced_ratio': {0: 1, 1: 0.5}}, 'Logistic Regression Classifier':{'penalty': 'l2', 'C': 1.0, 'n_jobs': -1, 'multi_class': 'auto', 'solver': 'lbfgs'}}, random_seed=0)
Adding ensemble methods to AutoML¶
Stacking¶
Stacking is an ensemble machine learning algorithm that involves training a model to best combine the predictions of several base learning algorithms. First, each base learning algorithms is trained using the given data. Then, the combining algorithm or meta-learner is trained on the predictions made by those base learning algorithms to make a final prediction.
AutoML enables stacking using the ensembling
flag during initalization; this is set to False
by default. The stacking ensemble pipeline runs in its own batch after a whole cycle of training has occurred (each allowed pipeline trains for one batch). Note that this means a large number of iterations may need to run before the stacking ensemble runs. It is also important to note that only the first CV fold is calculated for stacking ensembles because the model internally uses CV
folds.
[23]:
X, y = evalml.demos.load_breast_cancer()
automl_with_ensembling = AutoMLSearch(X_train=X, y_train=y,
problem_type="binary",
allowed_model_families=[ModelFamily.LINEAR_MODEL],
max_batches=4,
ensembling=True)
automl_with_ensembling.search()
Number of Features
Numeric 30
Number of training examples: 569
Targets
benign 62.74%
malignant 37.26%
Name: target, dtype: object
Generating pipelines to search over...
2 pipelines ready for search.
Ensembling will run every 3 batches.
*****************************
* Beginning pipeline search *
*****************************
Optimizing for Log Loss Binary.
Lower score is better.
Using SequentialEngine to train and score pipelines.
Searching up to 4 batches for a total of 14 pipelines.
Allowed model families: linear_model
Evaluating Baseline Pipeline: Mode Baseline Binary Classification Pipeline
Mode Baseline Binary Classification Pipeline:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 12.868
*****************************
* Evaluating Batch Number 1 *
*****************************
Elastic Net Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.077
Logistic Regression Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.077
High coefficient of variation (cv >= 0.2) within cross validation scores.
Logistic Regression Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
*****************************
* Evaluating Batch Number 2 *
*****************************
Logistic Regression Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.097
High coefficient of variation (cv >= 0.2) within cross validation scores.
Logistic Regression Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Logistic Regression Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.085
High coefficient of variation (cv >= 0.2) within cross validation scores.
Logistic Regression Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Logistic Regression Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.097
High coefficient of variation (cv >= 0.2) within cross validation scores.
Logistic Regression Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Logistic Regression Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.091
High coefficient of variation (cv >= 0.2) within cross validation scores.
Logistic Regression Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Logistic Regression Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.080
*****************************
* Evaluating Batch Number 3 *
*****************************
Elastic Net Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.075
High coefficient of variation (cv >= 0.2) within cross validation scores.
Elastic Net Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Elastic Net Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.075
High coefficient of variation (cv >= 0.2) within cross validation scores.
Elastic Net Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Elastic Net Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.079
Elastic Net Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.076
High coefficient of variation (cv >= 0.2) within cross validation scores.
Elastic Net Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Elastic Net Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.075
High coefficient of variation (cv >= 0.2) within cross validation scores.
Elastic Net Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
*****************************
* Evaluating Batch Number 4 *
*****************************
Sklearn Stacked Ensemble Classification Pipeline:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.123
Search finished after 00:26
Best pipeline: Elastic Net Classifier w/ Imputer + Standard Scaler
Best pipeline Log Loss Binary: 0.075387
We can view more information about the stacking ensemble pipeline (which was the best performing pipeline) by calling .describe()
.
[24]:
automl_with_ensembling.best_pipeline.describe()
*******************************************************
* Elastic Net Classifier w/ Imputer + Standard Scaler *
*******************************************************
Problem Type: binary
Model Family: Linear
Number of features: 30
Pipeline Steps
==============
1. Imputer
* categorical_impute_strategy : most_frequent
* numeric_impute_strategy : median
* categorical_fill_value : None
* numeric_fill_value : None
2. Standard Scaler
3. Elastic Net Classifier
* penalty : elasticnet
* C : 8.123565600467177
* l1_ratio : 0.47997717237505744
* n_jobs : -1
* multi_class : auto
* solver : saga
Access raw results¶
The AutoMLSearch
class records detailed results information under the results
field, including information about the cross-validation scoring and parameters.
[25]:
automl.results
[25]:
{'pipeline_results': {0: {'id': 0,
'pipeline_name': 'Mode Baseline Binary Classification Pipeline',
'pipeline_class': evalml.pipelines.binary_classification_pipeline.BinaryClassificationPipeline,
'pipeline_summary': 'Baseline Classifier',
'parameters': {'Baseline Classifier': {'strategy': 'mode'}},
'mean_cv_score': 3.970423187263591,
'standard_deviation_cv_score': 0.26606000431837074,
'high_variance_cv': False,
'training_time': 0.9850878715515137,
'cv_data': [{'all_objective_scores': OrderedDict([('Log Loss Binary',
4.124033002377396),
('MCC Binary', 0.0),
('Gini', 0.0),
('AUC', 0.5),
('Precision', 0.0),
('F1', 0.0),
('Balanced Accuracy Binary', 0.5),
('Accuracy Binary', 0.8805970149253731),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 4.124033002377396,
'binary_classification_threshold': 9.16384630183206e-53},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
4.124033002377395),
('MCC Binary', 0.0),
('Gini', 0.0),
('AUC', 0.5),
('Precision', 0.0),
('F1', 0.0),
('Balanced Accuracy Binary', 0.5),
('Accuracy Binary', 0.8805970149253731),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 4.124033002377395,
'binary_classification_threshold': 9.16384630183206e-53},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
3.6632035570359824),
('MCC Binary', 0.0),
('Gini', 0.0),
('AUC', 0.5),
('Precision', 0.0),
('F1', 0.0),
('Balanced Accuracy Binary', 0.5),
('Accuracy Binary', 0.8939393939393939),
('# Training', 134),
('# Validation', 66)]),
'mean_cv_score': 3.6632035570359824,
'binary_classification_threshold': 9.16384630183206e-53}],
'percent_better_than_baseline_all_objectives': {'Log Loss Binary': 0,
'MCC Binary': 0,
'Gini': 0,
'AUC': 0,
'Precision': 0,
'F1': 0,
'Balanced Accuracy Binary': 0,
'Accuracy Binary': 0},
'percent_better_than_baseline': 0,
'validation_score': 4.124033002377396},
1: {'id': 1,
'pipeline_name': 'Elastic Net Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler',
'pipeline_class': evalml.pipelines.binary_classification_pipeline.BinaryClassificationPipeline,
'pipeline_summary': 'Elastic Net Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler',
'parameters': {'Imputer': {'categorical_impute_strategy': 'most_frequent',
'numeric_impute_strategy': 'mean',
'categorical_fill_value': None,
'numeric_fill_value': None},
'DateTime Featurization Component': {'features_to_extract': ['year',
'month',
'day_of_week',
'hour'],
'encode_as_categories': False,
'date_index': None},
'One Hot Encoder': {'top_n': 10,
'features_to_encode': None,
'categories': None,
'drop': 'if_binary',
'handle_unknown': 'ignore',
'handle_missing': 'error'},
'SMOTENC Oversampler': {'sampling_ratio': 0.25,
'k_neighbors_default': 5,
'n_jobs': -1,
'sampling_ratio_dict': None,
'categorical_features': [3,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59],
'k_neighbors': 5},
'Elastic Net Classifier': {'penalty': 'elasticnet',
'C': 1.0,
'l1_ratio': 0.15,
'n_jobs': -1,
'multi_class': 'auto',
'solver': 'saga'}},
'mean_cv_score': 0.5118084226551022,
'standard_deviation_cv_score': 0.07499222153032764,
'high_variance_cv': False,
'training_time': 2.7400929927825928,
'cv_data': [{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.590516914375052),
('MCC Binary', 0.17518582316850065),
('Gini', 0.19491525423728806),
('AUC', 0.597457627118644),
('Precision', 0.2857142857142857),
('F1', 0.26666666666666666),
('Balanced Accuracy Binary', 0.5826271186440678),
('Accuracy Binary', 0.835820895522388),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.590516914375052,
'binary_classification_threshold': 0.48089822234602875},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.44118816828058105),
('MCC Binary', 0.2957528252716689),
('Gini', 0.4194915254237288),
('AUC', 0.7097457627118644),
('Precision', 0.5),
('F1', 0.3333333333333333),
('Balanced Accuracy Binary', 0.6080508474576272),
('Accuracy Binary', 0.8805970149253731),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.44118816828058105,
'binary_classification_threshold': 0.7518116371406225},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.5037201853096736),
('MCC Binary', 0.035350118786872956),
('Gini', 0.2590799031476996),
('AUC', 0.6295399515738498),
('Precision', 0.12),
('F1', 0.1875),
('Balanced Accuracy Binary', 0.5278450363196125),
('Accuracy Binary', 0.6060606060606061),
('# Training', 134),
('# Validation', 66)]),
'mean_cv_score': 0.5037201853096736,
'binary_classification_threshold': 0.10568708806540947}],
'percent_better_than_baseline_all_objectives': {'Log Loss Binary': 87.10947426720426,
'MCC Binary': inf,
'Gini': inf,
'AUC': 14.558111380145277,
'Precision': 30.19047619047619,
'F1': 26.25,
'Balanced Accuracy Binary': 7.284100080710254,
'Accuracy Binary': -11.08849690939243},
'percent_better_than_baseline': 87.10947426720426,
'validation_score': 0.590516914375052},
2: {'id': 2,
'pipeline_name': 'Decision Tree Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'pipeline_class': evalml.pipelines.binary_classification_pipeline.BinaryClassificationPipeline,
'pipeline_summary': 'Decision Tree Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'parameters': {'Imputer': {'categorical_impute_strategy': 'most_frequent',
'numeric_impute_strategy': 'mean',
'categorical_fill_value': None,
'numeric_fill_value': None},
'DateTime Featurization Component': {'features_to_extract': ['year',
'month',
'day_of_week',
'hour'],
'encode_as_categories': False,
'date_index': None},
'One Hot Encoder': {'top_n': 10,
'features_to_encode': None,
'categories': None,
'drop': 'if_binary',
'handle_unknown': 'ignore',
'handle_missing': 'error'},
'SMOTENC Oversampler': {'sampling_ratio': 0.25,
'k_neighbors_default': 5,
'n_jobs': -1,
'sampling_ratio_dict': None,
'categorical_features': [3,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59],
'k_neighbors': 5},
'Decision Tree Classifier': {'criterion': 'gini',
'max_features': 'auto',
'max_depth': 6,
'min_samples_split': 2,
'min_weight_fraction_leaf': 0.0}},
'mean_cv_score': 2.956956288246977,
'standard_deviation_cv_score': 3.084438905133218,
'high_variance_cv': True,
'training_time': 2.025935649871826,
'cv_data': [{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.651556943513563),
('MCC Binary', 0.7712055916006633),
('Gini', 0.6207627118644068),
('AUC', 0.8103813559322034),
('Precision', 1.0),
('F1', 0.7692307692307693),
('Balanced Accuracy Binary', 0.8125),
('Accuracy Binary', 0.9552238805970149),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.651556943513563,
'binary_classification_threshold': 0.9999999885588493},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
1.7585681792927779),
('MCC Binary', 0.4208952550769721),
('Gini', 0.379237288135593),
('AUC', 0.6896186440677965),
('Precision', 0.6),
('F1', 0.4615384615384615),
('Balanced Accuracy Binary', 0.6705508474576272),
('Accuracy Binary', 0.8955223880597015),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 1.7585681792927779,
'binary_classification_threshold': 0.9999999885588493},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
6.460743741934591),
('MCC Binary', -0.20116515012026231),
('Gini', -0.29539951573849876),
('AUC', 0.3523002421307506),
('Precision', 0.06521739130434782),
('F1', 0.11320754716981131),
('Balanced Accuracy Binary', 0.3498789346246973),
('Accuracy Binary', 0.2878787878787879),
('# Training', 134),
('# Validation', 66)]),
'mean_cv_score': 6.460743741934591,
'binary_classification_threshold': 0.1568627424310231}],
'percent_better_than_baseline_all_objectives': {'Log Loss Binary': 25.52541256225873,
'MCC Binary': inf,
'Gini': inf,
'AUC': 11.743341404358354,
'Precision': 55.5072463768116,
'F1': 44.79922593130141,
'Balanced Accuracy Binary': 11.097659402744153,
'Accuracy Binary': -17.21694557515452},
'percent_better_than_baseline': 25.52541256225873,
'validation_score': 0.651556943513563},
3: {'id': 3,
'pipeline_name': 'Random Forest Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'pipeline_class': evalml.pipelines.binary_classification_pipeline.BinaryClassificationPipeline,
'pipeline_summary': 'Random Forest Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'parameters': {'Imputer': {'categorical_impute_strategy': 'most_frequent',
'numeric_impute_strategy': 'mean',
'categorical_fill_value': None,
'numeric_fill_value': None},
'DateTime Featurization Component': {'features_to_extract': ['year',
'month',
'day_of_week',
'hour'],
'encode_as_categories': False,
'date_index': None},
'One Hot Encoder': {'top_n': 10,
'features_to_encode': None,
'categories': None,
'drop': 'if_binary',
'handle_unknown': 'ignore',
'handle_missing': 'error'},
'SMOTENC Oversampler': {'sampling_ratio': 0.25,
'k_neighbors_default': 5,
'n_jobs': -1,
'sampling_ratio_dict': None,
'categorical_features': [3,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59],
'k_neighbors': 5},
'Random Forest Classifier': {'n_estimators': 100,
'max_depth': 6,
'n_jobs': -1}},
'mean_cv_score': 0.2856133806139974,
'standard_deviation_cv_score': 0.041115539258178,
'high_variance_cv': False,
'training_time': 2.6432762145996094,
'cv_data': [{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.26369520661129536),
('MCC Binary', 0.47636443708895493),
('Gini', 0.6483050847457628),
('AUC', 0.8241525423728814),
('Precision', 1.0),
('F1', 0.4),
('Balanced Accuracy Binary', 0.625),
('Accuracy Binary', 0.9104477611940298),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.26369520661129536,
'binary_classification_threshold': 0.4988241268809967},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.33304413887923806),
('MCC Binary', 0.4900218379501181),
('Gini', 0.423728813559322),
('AUC', 0.711864406779661),
('Precision', 0.75),
('F1', 0.5),
('Balanced Accuracy Binary', 0.6790254237288136),
('Accuracy Binary', 0.9104477611940298),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.33304413887923806,
'binary_classification_threshold': 0.5065550313835498},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.2601007963514588),
('MCC Binary', 0.6335302236023843),
('Gini', 0.757869249394673),
('AUC', 0.8789346246973365),
('Precision', 1.0),
('F1', 0.6),
('Balanced Accuracy Binary', 0.7142857142857143),
('Accuracy Binary', 0.9393939393939394),
('# Training', 134),
('# Validation', 66)]),
'mean_cv_score': 0.2601007963514588,
'binary_classification_threshold': 0.4459844896470452}],
'percent_better_than_baseline_all_objectives': {'Log Loss Binary': 92.80647509992905,
'MCC Binary': inf,
'Gini': inf,
'AUC': 30.498385794995965,
'Precision': 91.66666666666666,
'F1': 50.0,
'Balanced Accuracy Binary': 17.277037933817596,
'Accuracy Binary': 3.505201266395308},
'percent_better_than_baseline': 92.80647509992905,
'validation_score': 0.26369520661129536},
4: {'id': 4,
'pipeline_name': 'LightGBM Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'pipeline_class': evalml.pipelines.binary_classification_pipeline.BinaryClassificationPipeline,
'pipeline_summary': 'LightGBM Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'parameters': {'Imputer': {'categorical_impute_strategy': 'most_frequent',
'numeric_impute_strategy': 'mean',
'categorical_fill_value': None,
'numeric_fill_value': None},
'DateTime Featurization Component': {'features_to_extract': ['year',
'month',
'day_of_week',
'hour'],
'encode_as_categories': False,
'date_index': None},
'One Hot Encoder': {'top_n': 10,
'features_to_encode': None,
'categories': None,
'drop': 'if_binary',
'handle_unknown': 'ignore',
'handle_missing': 'error'},
'SMOTENC Oversampler': {'sampling_ratio': 0.25,
'k_neighbors_default': 5,
'n_jobs': -1,
'sampling_ratio_dict': None,
'categorical_features': [3,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59],
'k_neighbors': 5},
'LightGBM Classifier': {'boosting_type': 'gbdt',
'learning_rate': 0.1,
'n_estimators': 100,
'max_depth': 0,
'num_leaves': 31,
'min_child_samples': 20,
'n_jobs': -1,
'bagging_freq': 0,
'bagging_fraction': 0.9}},
'mean_cv_score': 0.30863594948686357,
'standard_deviation_cv_score': 0.20387814963979614,
'high_variance_cv': True,
'training_time': 2.268958806991577,
'cv_data': [{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.23494740261438743),
('MCC Binary', 0.4900218379501181),
('Gini', 0.7881355932203391),
('AUC', 0.8940677966101696),
('Precision', 0.75),
('F1', 0.5),
('Balanced Accuracy Binary', 0.6790254237288136),
('Accuracy Binary', 0.9104477611940298),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.23494740261438743,
'binary_classification_threshold': 0.5037478165498673},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.5391133772263208),
('MCC Binary', 0.4900218379501181),
('Gini', 0.27118644067796605),
('AUC', 0.635593220338983),
('Precision', 0.75),
('F1', 0.5),
('Balanced Accuracy Binary', 0.6790254237288136),
('Accuracy Binary', 0.9104477611940298),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.5391133772263208,
'binary_classification_threshold': 0.7736716431132877},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.15184706861988254),
('MCC Binary', 0.3600976668493281),
('Gini', 0.7869249394673123),
('AUC', 0.8934624697336562),
('Precision', 1.0),
('F1', 0.25),
('Balanced Accuracy Binary', 0.5714285714285714),
('Accuracy Binary', 0.9090909090909091),
('# Training', 134),
('# Validation', 66)]),
'mean_cv_score': 0.15184706861988254,
'binary_classification_threshold': 0.9385567379765596}],
'percent_better_than_baseline_all_objectives': {'Log Loss Binary': 92.22662333635083,
'MCC Binary': inf,
'Gini': inf,
'AUC': 30.77078288942697,
'Precision': 83.33333333333334,
'F1': 41.66666666666667,
'Balanced Accuracy Binary': 14.315980629539949,
'Accuracy Binary': 2.4951002562942914},
'percent_better_than_baseline': 92.22662333635083,
'validation_score': 0.23494740261438743},
5: {'id': 5,
'pipeline_name': 'Logistic Regression Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler',
'pipeline_class': evalml.pipelines.binary_classification_pipeline.BinaryClassificationPipeline,
'pipeline_summary': 'Logistic Regression Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler + Standard Scaler',
'parameters': {'Imputer': {'categorical_impute_strategy': 'most_frequent',
'numeric_impute_strategy': 'mean',
'categorical_fill_value': None,
'numeric_fill_value': None},
'DateTime Featurization Component': {'features_to_extract': ['year',
'month',
'day_of_week',
'hour'],
'encode_as_categories': False,
'date_index': None},
'One Hot Encoder': {'top_n': 10,
'features_to_encode': None,
'categories': None,
'drop': 'if_binary',
'handle_unknown': 'ignore',
'handle_missing': 'error'},
'SMOTENC Oversampler': {'sampling_ratio': 0.25,
'k_neighbors_default': 5,
'n_jobs': -1,
'sampling_ratio_dict': None,
'categorical_features': [3,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59],
'k_neighbors': 5},
'Logistic Regression Classifier': {'penalty': 'l2',
'C': 1.0,
'n_jobs': -1,
'multi_class': 'auto',
'solver': 'lbfgs'}},
'mean_cv_score': 0.5519600330274397,
'standard_deviation_cv_score': 0.08269486722266915,
'high_variance_cv': False,
'training_time': 4.0118489265441895,
'cv_data': [{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.6286458411705291),
('MCC Binary', 0.17518582316850065),
('Gini', 0.1652542372881356),
('AUC', 0.5826271186440678),
('Precision', 0.2857142857142857),
('F1', 0.26666666666666666),
('Balanced Accuracy Binary', 0.5826271186440678),
('Accuracy Binary', 0.835820895522388),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.6286458411705291,
'binary_classification_threshold': 0.4313366338786227},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.46434334092355634),
('MCC Binary', 0.14283901342792224),
('Gini', 0.4067796610169492),
('AUC', 0.7033898305084746),
('Precision', 0.3333333333333333),
('F1', 0.18181818181818182),
('Balanced Accuracy Binary', 0.5455508474576272),
('Accuracy Binary', 0.8656716417910447),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.46434334092355634,
'binary_classification_threshold': 0.7298626702409028},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.5628909169882338),
('MCC Binary', 0.13468820490061437),
('Gini', 0.21549636803874073),
('AUC', 0.6077481840193704),
('Precision', 0.17647058823529413),
('F1', 0.25),
('Balanced Accuracy Binary', 0.5956416464891041),
('Accuracy Binary', 0.7272727272727273),
('# Training', 134),
('# Validation', 66)]),
'mean_cv_score': 0.5628909169882338,
'binary_classification_threshold': 0.16920770831511384}],
'percent_better_than_baseline_all_objectives': {'Log Loss Binary': 86.09820648846629,
'MCC Binary': inf,
'Gini': inf,
'AUC': 13.125504439063763,
'Precision': 26.517273576097107,
'F1': 23.282828282828284,
'Balanced Accuracy Binary': 7.4606537530266355,
'Accuracy Binary': -7.5456053067993185},
'percent_better_than_baseline': 86.09820648846629,
'validation_score': 0.6286458411705291},
6: {'id': 6,
'pipeline_name': 'XGBoost Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'pipeline_class': evalml.pipelines.binary_classification_pipeline.BinaryClassificationPipeline,
'pipeline_summary': 'XGBoost Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'parameters': {'Imputer': {'categorical_impute_strategy': 'most_frequent',
'numeric_impute_strategy': 'mean',
'categorical_fill_value': None,
'numeric_fill_value': None},
'DateTime Featurization Component': {'features_to_extract': ['year',
'month',
'day_of_week',
'hour'],
'encode_as_categories': False,
'date_index': None},
'One Hot Encoder': {'top_n': 10,
'features_to_encode': None,
'categories': None,
'drop': 'if_binary',
'handle_unknown': 'ignore',
'handle_missing': 'error'},
'SMOTENC Oversampler': {'sampling_ratio': 0.25,
'k_neighbors_default': 5,
'n_jobs': -1,
'sampling_ratio_dict': None,
'categorical_features': [3,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59],
'k_neighbors': 5},
'XGBoost Classifier': {'eta': 0.1,
'max_depth': 6,
'min_child_weight': 1,
'n_estimators': 100,
'n_jobs': -1}},
'mean_cv_score': 0.2787074593034545,
'standard_deviation_cv_score': 0.19072502137726743,
'high_variance_cv': True,
'training_time': 2.699519157409668,
'cv_data': [{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.20263786688400182),
('MCC Binary', 0.6842908506285673),
('Gini', 0.7838983050847457),
('AUC', 0.8919491525423728),
('Precision', 1.0),
('F1', 0.6666666666666666),
('Balanced Accuracy Binary', 0.75),
('Accuracy Binary', 0.9402985074626866),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.20263786688400182,
'binary_classification_threshold': 0.8503084678293262},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.4957285583724021),
('MCC Binary', 0.20588632450454833),
('Gini', 0.2966101694915255),
('AUC', 0.6483050847457628),
('Precision', 0.5),
('F1', 0.2),
('Balanced Accuracy Binary', 0.5540254237288136),
('Accuracy Binary', 0.8805970149253731),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.4957285583724021,
'binary_classification_threshold': 0.9268544884142358},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.13775595265395954),
('MCC Binary', 0.3600976668493281),
('Gini', 0.7772397094430992),
('AUC', 0.8886198547215496),
('Precision', 1.0),
('F1', 0.25),
('Balanced Accuracy Binary', 0.5714285714285714),
('Accuracy Binary', 0.9090909090909091),
('# Training', 134),
('# Validation', 66)]),
'mean_cv_score': 0.13775595265395954,
'binary_classification_threshold': 0.9457477876739043}],
'percent_better_than_baseline_all_objectives': {'Log Loss Binary': 92.98040923704308,
'MCC Binary': inf,
'Gini': inf,
'AUC': 30.96246973365617,
'Precision': 83.33333333333334,
'F1': 37.22222222222222,
'Balanced Accuracy Binary': 12.51513317191283,
'Accuracy Binary': 2.4951002562942914},
'percent_better_than_baseline': 92.98040923704308,
'validation_score': 0.20263786688400182},
7: {'id': 7,
'pipeline_name': 'Extra Trees Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'pipeline_class': evalml.pipelines.binary_classification_pipeline.BinaryClassificationPipeline,
'pipeline_summary': 'Extra Trees Classifier w/ Imputer + DateTime Featurization Component + One Hot Encoder + SMOTENC Oversampler',
'parameters': {'Imputer': {'categorical_impute_strategy': 'most_frequent',
'numeric_impute_strategy': 'mean',
'categorical_fill_value': None,
'numeric_fill_value': None},
'DateTime Featurization Component': {'features_to_extract': ['year',
'month',
'day_of_week',
'hour'],
'encode_as_categories': False,
'date_index': None},
'One Hot Encoder': {'top_n': 10,
'features_to_encode': None,
'categories': None,
'drop': 'if_binary',
'handle_unknown': 'ignore',
'handle_missing': 'error'},
'SMOTENC Oversampler': {'sampling_ratio': 0.25,
'k_neighbors_default': 5,
'n_jobs': -1,
'sampling_ratio_dict': None,
'categorical_features': [3,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59],
'k_neighbors': 5},
'Extra Trees Classifier': {'n_estimators': 100,
'max_features': 'auto',
'max_depth': 6,
'min_samples_split': 2,
'min_weight_fraction_leaf': 0.0,
'n_jobs': -1}},
'mean_cv_score': 0.33828572013370833,
'standard_deviation_cv_score': 0.009380537483031018,
'high_variance_cv': False,
'training_time': 2.5175821781158447,
'cv_data': [{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.32901507195041363),
('MCC Binary', 0.3624510999859961),
('Gini', 0.5677966101694916),
('AUC', 0.7838983050847458),
('Precision', 0.4),
('F1', 0.4444444444444445),
('Balanced Accuracy Binary', 0.6991525423728814),
('Accuracy Binary', 0.8507462686567164),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.32901507195041363,
'binary_classification_threshold': 0.24464061936922427},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.3380696737832299),
('MCC Binary', -0.045325960909933655),
('Gini', 0.4279661016949152),
('AUC', 0.7139830508474576),
('Precision', 0.0),
('F1', 0.0),
('Balanced Accuracy Binary', 0.4915254237288136),
('Accuracy Binary', 0.8656716417910447),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.3380696737832299,
'binary_classification_threshold': 0.3074199530907704},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.3477724146674814),
('MCC Binary', 0.27835560025568845),
('Gini', 0.43825665859564156),
('AUC', 0.7191283292978208),
('Precision', 0.22727272727272727),
('F1', 0.3448275862068965),
('Balanced Accuracy Binary', 0.7130750605326877),
('Accuracy Binary', 0.7121212121212122),
('# Training', 134),
('# Validation', 66)]),
'mean_cv_score': 0.3477724146674814,
'binary_classification_threshold': 0.2199210188616361}],
'percent_better_than_baseline_all_objectives': {'Log Loss Binary': 91.47985733060223,
'MCC Binary': inf,
'Gini': inf,
'AUC': 23.900322841000797,
'Precision': 20.90909090909091,
'F1': 26.309067688378036,
'Balanced Accuracy Binary': 13.458434221146087,
'Accuracy Binary': -7.553143374038884},
'percent_better_than_baseline': 91.47985733060223,
'validation_score': 0.32901507195041363},
8: {'id': 8,
'pipeline_name': 'CatBoost Classifier w/ Imputer + DateTime Featurization Component + SMOTENC Oversampler',
'pipeline_class': evalml.pipelines.binary_classification_pipeline.BinaryClassificationPipeline,
'pipeline_summary': 'CatBoost Classifier w/ Imputer + DateTime Featurization Component + SMOTENC Oversampler',
'parameters': {'Imputer': {'categorical_impute_strategy': 'most_frequent',
'numeric_impute_strategy': 'mean',
'categorical_fill_value': None,
'numeric_fill_value': None},
'DateTime Featurization Component': {'features_to_extract': ['year',
'month',
'day_of_week',
'hour'],
'encode_as_categories': False,
'date_index': None},
'SMOTENC Oversampler': {'sampling_ratio': 0.25,
'k_neighbors_default': 5,
'n_jobs': -1,
'sampling_ratio_dict': None,
'categorical_features': [3, 4, 5, 6, 9, 10],
'k_neighbors': 5},
'CatBoost Classifier': {'n_estimators': 10,
'eta': 0.03,
'max_depth': 6,
'bootstrap_type': None,
'silent': True,
'allow_writing_files': False,
'n_jobs': -1}},
'mean_cv_score': 0.6018191346985708,
'standard_deviation_cv_score': 0.007246095254215931,
'high_variance_cv': False,
'training_time': 1.0775504112243652,
'cv_data': [{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.5936927052183711),
('MCC Binary', 0.7712055916006633),
('Gini', 0.7796610169491525),
('AUC', 0.8898305084745762),
('Precision', 1.0),
('F1', 0.7692307692307693),
('Balanced Accuracy Binary', 0.8125),
('Accuracy Binary', 0.9552238805970149),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.5936927052183711,
'binary_classification_threshold': 0.498623875482405},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.6076076767585368),
('MCC Binary', 0.47636443708895493),
('Gini', 0.12076271186440679),
('AUC', 0.5603813559322034),
('Precision', 1.0),
('F1', 0.4),
('Balanced Accuracy Binary', 0.625),
('Accuracy Binary', 0.9104477611940298),
('# Training', 133),
('# Validation', 67)]),
'mean_cv_score': 0.6076076767585368,
'binary_classification_threshold': 0.5007469614241519},
{'all_objective_scores': OrderedDict([('Log Loss Binary',
0.6041570221188047),
('MCC Binary', 0.7469064529073725),
('Gini', 0.8692493946731235),
('AUC', 0.9346246973365617),
('Precision', 0.8333333333333334),
('F1', 0.7692307692307692),
('Balanced Accuracy Binary', 0.8486682808716708),
('Accuracy Binary', 0.9545454545454546),
('# Training', 134),
('# Validation', 66)]),
'mean_cv_score': 0.6041570221188047,
'binary_classification_threshold': 0.47437131050216075}],
'percent_better_than_baseline_all_objectives': {'Log Loss Binary': 84.84244358059615,
'MCC Binary': inf,
'Gini': inf,
'AUC': 29.49455205811139,
'Precision': 94.44444444444446,
'F1': 64.61538461538461,
'Balanced Accuracy Binary': 26.205609362389026,
'Accuracy Binary': 5.502789084878645},
'percent_better_than_baseline': 84.84244358059615,
'validation_score': 0.5936927052183711}},
'search_order': [0, 1, 2, 3, 4, 5, 6, 7, 8]}
Parallel AutoML¶
By default, all pipelines in an AutoML batch are evaluated in series. Pipelines can be evaluated in parallel to improve performance during AutoML search. This is accomplished by a futures style submission and evaluation of pipelines in a batch. As of this writing, the pipelines use a threaded model for concurrent evaluation. This is similar to the currently implemented n_jobs
parameter in the estimators, which uses increased numbers of threads to train and evaluate estimators.
Parallelism with Concurrent Futures¶
The EngineBase
class is robust and extensible enough to support futures-like implementations from a variety of libraries. The CFEngine
extends the EngineBase
to use the native Python concurrent.futures library. The CFEngine
supports both thread- and process-level parallelism. The type of parallelism can be chosen using either the ThreadPoolExecutor
or the ProcessPoolExecutor
. If either executor is passed a max_workers
parameter, it will set the number of processes and
threads spawned. If not, the default number of processes will be equal to the number of processors available and the number of threads set to five times the number of processors available.
[26]:
from concurrent.futures import ThreadPoolExecutor
from evalml.automl.engine import CFEngine
from evalml.automl.engine.cf_engine import CFClient
# Use thread-level parallelism
threaded_cf_engine = CFEngine(CFClient(ThreadPoolExecutor()))
automl_cf_threaded = AutoMLSearch(X_train=X, y_train=y,
problem_type="binary",
allowed_model_families=[ModelFamily.LINEAR_MODEL],
engine=threaded_cf_engine)
automl_cf_threaded.search(show_iteration_plot = False)
Using default limit of max_batches=1.
Generating pipelines to search over...
2 pipelines ready for search.
*****************************
* Beginning pipeline search *
*****************************
Optimizing for Log Loss Binary.
Lower score is better.
Using CFEngine to train and score pipelines.
Searching up to 1 batches for a total of 3 pipelines.
Allowed model families: linear_model
Evaluating Baseline Pipeline: Mode Baseline Binary Classification Pipeline
Mode Baseline Binary Classification Pipeline:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 12.868
*****************************
* Evaluating Batch Number 1 *
*****************************
Logistic Regression Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.077
High coefficient of variation (cv >= 0.2) within cross validation scores.
Logistic Regression Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Elastic Net Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.077
Search finished after 00:04
Best pipeline: Logistic Regression Classifier w/ Imputer + Standard Scaler
Best pipeline Log Loss Binary: 0.076807
Note: the cell demonstrating process-level parallelism is commented out due to incompatibility with our ReadTheDocs build. It can be run successfully locally.
from concurrent.futures import ProcessPoolExecutor
# Repeat the process but using process-level parallelism
process_cf_engine = CFEngine(CFClient(ProcessPoolExecutor()))
automl_cf_process = AutoMLSearch(X_train=X, y_train=y,
problem_type="binary",
engine=process_cf_engine)
automl_cf_process.search(show_iteration_plot = False)
Parallelism with Dask¶
Thread or process level parallelism can be explicitly invoked for the DaskEngine
(as well as the CFEngine
). The processes
can be set to True
and the number of processes set using n_workers
. If processes
is set to False
, then the resulting parallelism will be threaded and n_workers
will represent the threads used. Examples of both follow.
[27]:
from dask.distributed import Client, LocalCluster
from evalml.automl.engine import DaskEngine
dask_engine_p2 = DaskEngine(Client(LocalCluster(processes=True, n_workers = 2)))
automl_dask_p2 = AutoMLSearch(X_train=X, y_train=y,
problem_type="binary",
allowed_model_families=[ModelFamily.LINEAR_MODEL],
engine=dask_engine_p2)
automl_dask_p2.search(show_iteration_plot = False)
del(dask_engine_p2)
Using default limit of max_batches=1.
Generating pipelines to search over...
2 pipelines ready for search.
*****************************
* Beginning pipeline search *
*****************************
Optimizing for Log Loss Binary.
Lower score is better.
Using DaskEngine to train and score pipelines.
Searching up to 1 batches for a total of 3 pipelines.
Allowed model families: linear_model
Evaluating Baseline Pipeline: Mode Baseline Binary Classification Pipeline
Mode Baseline Binary Classification Pipeline:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 12.868
*****************************
* Evaluating Batch Number 1 *
*****************************
Elastic Net Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.077
Logistic Regression Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.077
High coefficient of variation (cv >= 0.2) within cross validation scores.
Logistic Regression Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Search finished after 00:09
Best pipeline: Logistic Regression Classifier w/ Imputer + Standard Scaler
Best pipeline Log Loss Binary: 0.076807
[28]:
dask_engine_t4 = DaskEngine(Client(LocalCluster(processes=False, n_workers = 4)))
automl_dask_t4 = AutoMLSearch(X_train=X, y_train=y,
problem_type="binary",
allowed_model_families=[ModelFamily.LINEAR_MODEL],
engine=dask_engine_t4)
automl_dask_t4.search(show_iteration_plot = False)
Using default limit of max_batches=1.
Generating pipelines to search over...
2 pipelines ready for search.
*****************************
* Beginning pipeline search *
*****************************
Optimizing for Log Loss Binary.
Lower score is better.
Using DaskEngine to train and score pipelines.
Searching up to 1 batches for a total of 3 pipelines.
Allowed model families: linear_model
Evaluating Baseline Pipeline: Mode Baseline Binary Classification Pipeline
/home/docs/checkouts/readthedocs.org/user_builds/feature-labs-inc-evalml/envs/v0.30.2/lib/python3.8/site-packages/distributed/node.py:160: UserWarning:
Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 34469 instead
Mode Baseline Binary Classification Pipeline:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 12.868
*****************************
* Evaluating Batch Number 1 *
*****************************
Elastic Net Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.077
Logistic Regression Classifier w/ Imputer + Standard Scaler:
Starting cross validation
Finished cross validation - mean Log Loss Binary: 0.077
High coefficient of variation (cv >= 0.2) within cross validation scores.
Logistic Regression Classifier w/ Imputer + Standard Scaler may not perform as estimated on unseen data.
Search finished after 00:05
Best pipeline: Logistic Regression Classifier w/ Imputer + Standard Scaler
Best pipeline Log Loss Binary: 0.076807
As we can see, a significant performance gain can result from simply using something other than the default SequentialEngine
, ranging from a 100% speed up with multiple processes to 250% speedup with multiple threads!
[29]:
print("Sequential search duration: %s" % str(automl.search_duration))
print("Concurrent futures (threaded) search duration: %s" % str(automl_cf_threaded.search_duration))
print("Dask (two processes) search duration: %s" % str(automl_dask_p2.search_duration))
print("Dask (four threads)search duration: %s" % str(automl_dask_t4.search_duration))
Sequential search duration: 21.94455862045288
Concurrent futures (threaded) search duration: 4.72780442237854
Dask (two processes) search duration: 9.470119953155518
Dask (four threads)search duration: 5.739243268966675