h2o AutoML algo_parameters usage

Viewed 79

I am trying to run H2OAutoML in a specific way. I am only running XGBOOST, and I only want stratified folds, along with only using booster = 'gbtree' (i.e. I don't want booster = 'dart' in the hyper-parameter search)

I have tried:

    aml = H2OAutoML(
        nfolds=5, 
        include_algos=['XGBoost'], 
        sort_metric='auc', 
        seed=1, 
        max_runtime_secs=10,
        algo_parameters=dict(booster = 'gbtree')
    )

But get the error:

  Error: Illegal value for field: algo_parameters: booster
  Request: POST /99/AutoMLBuilder
    json: {'build_control': {'stopping_criteria': {'max_runtime_secs': 10, 
    'stopping_metric': 'AUTO', 'stopping_rounds': 3, 'seed': 1}, 'nfolds': 5, 
    'balance_classes': False, 'max_after_balance_size': 5.0, 
   'keep_cross_validation_models': False, 'keep_cross_validation_fold_assignment': 
   False, 'keep_cross_validation_predictions': False}, 'build_models': 
   {'include_algos': ['XGBoost'], 'exploitation_ratio': 0, 'algo_parameters': 
   [{'scope': 'any', 'name': 'booster', 'value': 'gbtree'}]}, 'input_spec': 
   {'sort_metric': 'auc', 'training_frame': 'py_1_sid_928f', 'response_column': 
   'successful', 'weights_column': 'weight', 'ignored_columns': ['C1']}}
1 Answers

This is an undocumented parameter (used internally for testing), so although I will post how to do it here, you should not count on this parameter as something that will always be available. Use at your own risk!

The reason that you're getting this error is that this is only available when you start H2O with special Java flags. In Python, you have to start H2O like this:

# Start H2O with custom algo_parameters option enabled
h2o.init(jvm_custom_args=["-Dsys.ai.h2o.automl.algo_parameters.all.enabled=true"])

And then this will work:

aml = H2OAutoML(
    nfolds=5, 
    include_algos=['XGBoost'], 
    sort_metric='auc', 
    seed=1, 
    max_runtime_secs=10,
    algo_parameters=dict(XGBoost__booster = 'gbtree')
)

Note: you should pre-pend the algorithm name to the parameter name with two underscores, so it knows which algo to use it in, even if you only include XGBoost, it's good to be verbose.

Related