class_docstr: Automatic Machine Learning
  
  The Automatic Machine Learning (AutoML) function automates the supervised machine learning model training process.
  It trains several models, cross-validated by default, by using the following available algorithms:
  
  - XGBoost
  - GBM (Gradient Boosting Machine)
  - GLM (Generalized Linear Model)
  - DRF (Distributed Random Forest)
  - XRT (eXtremely Randomized Trees)
  - DeepLearning (Fully Connected Deep Neural Network)
  
  It also applies HPO on the following algorithms:
  
  - XGBoost
  - GBM
  - DeepLearning
  
  In some cases, there will not be enough time to complete all the algorithms, so some may be missing from the
  leaderboard. 
  Finally, AutoML also trains several Stacked Ensemble models at various stages during the run.
  Mainly two kinds of Stacked Ensemble models are trained:
  
  - one of all available models at time t
  - one of only the best models of each kind at time t.
  
  Note that Stacked Ensemble models are trained only if there isn't another stacked ensemble with the same base models.
  
  :examples:
  
  >>> import h2o
  >>> from h2o.automl import H2OAutoML
  >>> h2o.init()
  >>> # Import a sample binary outcome train/test set into H2O
  >>> train = h2o.import_file("https://s3.amazonaws.com/erin-data/higgs/higgs_train_10k.csv")
  >>> test = h2o.import_file("https://s3.amazonaws.com/erin-data/higgs/higgs_test_5k.csv")
  >>> # Identify the response and set of predictors
  >>> y = "response"
  >>> x = list(train.columns)  #if x is defined as all columns except the response, then x is not required
  >>> x.remove(y)
  >>> # For binary classification, response should be a factor
  >>> train[y] = train[y].asfactor()
  >>> test[y] = test[y].asfactor()
  >>> # Run AutoML for 30 seconds
  >>> aml = H2OAutoML(max_runtime_secs = 30)
  >>> aml.train(x = x, y = y, training_frame = train)
  >>> # Print Leaderboard (ranked by xval metrics)
  >>> aml.leaderboard
  >>> # (Optional) Evaluate performance on a test set
  >>> perf = aml.leader.model_performance(test)
  >>> perf.auc()
docstr: Begins an AutoML task, a background task that automatically builds a number of models
  with various algorithms and tracks their performance in a leaderboard. At any point 
  in the process you may use H2O's performance or prediction functions on the resulting 
  models.
  
  :param x: A list of column names or indices indicating the predictor columns.
  :param y: An index or a column name indicating the response column.
  :param fold_column: The name or index of the column in training_frame that holds per-row fold
      assignments.
  :param weights_column: The name or index of the column in training_frame that holds per-row weights.
  :param training_frame: The H2OFrame having the columns indicated by x and y (as well as any
      additional columns specified by fold_column or weights_column).
  :param validation_frame: H2OFrame with validation data. This argument is ignored unless the user sets 
      nfolds = 0. If cross-validation is turned off, then a validation frame can be specified and used 
      for early stopping of individual models and early stopping of the grid searches.  By default and 
      when nfolds > 1, cross-validation metrics will be used for early stopping and thus validation_frame will be ignored.
  :param leaderboard_frame: H2OFrame with test data for scoring the leaderboard.  This is optional and
      if this is set to None (the default), then cross-validation metrics will be used to generate the leaderboard 
      rankings instead.
  :param blending_frame: H2OFrame used to train the the metalearning algorithm in Stacked Ensembles (instead of relying on cross-validated predicted values).
      This is optional, but when provided, it is also recommended to disable cross validation 
      by setting `nfolds=0` and to provide a leaderboard frame for scoring purposes.
  
  :returns: An H2OAutoML object.
  
  :examples:
  
  >>> # Set up an H2OAutoML object
  >>> aml = H2OAutoML(max_runtime_secs=30)
  >>> # Launch an AutoML run
  >>> aml.train(y=y, training_frame=train)
code: def train(
      self,
      x=None,
      y=None,
      training_frame=None,
      fold_column=None,
      weights_column=None,
      validation_frame=None,
      leaderboard_frame=None,
      blending_frame=None,
  ):
      """
      Begins an AutoML task, a background task that automatically builds a number of models
      with various algorithms and tracks their performance in a leaderboard. At any point
      in the process you may use H2O's performance or prediction functions on the resulting
      models.
  
      :param x: A list of column names or indices indicating the predictor columns.
      :param y: An index or a column name indicating the response column.
      :param fold_column: The name or index of the column in training_frame that holds per-row fold
          assignments.
      :param weights_column: The name or index of the column in training_frame that holds per-row weights.
      :param training_frame: The H2OFrame having the columns indicated by x and y (as well as any
          additional columns specified by fold_column or weights_column).
      :param validation_frame: H2OFrame with validation data. This argument is ignored unless the user sets
          nfolds = 0. If cross-validation is turned off, then a validation frame can be specified and used
          for early stopping of individual models and early stopping of the grid searches.  By default and
          when nfolds > 1, cross-validation metrics will be used for early stopping and thus validation_frame will be ignored.
      :param leaderboard_frame: H2OFrame with test data for scoring the leaderboard.  This is optional and
          if this is set to None (the default), then cross-validation metrics will be used to generate the leaderboard
          rankings instead.
      :param blending_frame: H2OFrame used to train the the metalearning algorithm in Stacked Ensembles (instead of relying on cross-validated predicted values).
          This is optional, but when provided, it is also recommended to disable cross validation
          by setting `nfolds=0` and to provide a leaderboard frame for scoring purposes.
  
      :returns: An H2OAutoML object.
  
      :examples:
  
      >>> # Set up an H2OAutoML object
      >>> aml = H2OAutoML(max_runtime_secs=30)
      >>> # Launch an AutoML run
      >>> aml.train(y=y, training_frame=train)
      """
      # Minimal required arguments are training_frame and y (response)
      self.training_frame = training_frame
  
      ncols = self.training_frame.ncols
      names = self.training_frame.names
  
      if y is None and self.response_column is None:
          raise H2OValueError(
              "The response column (y) is not set; please set it to the name of the column that you are trying to predict in your data."
          )
      elif y is not None:
          assert_is_type(y, int, str)
          if is_type(y, int):
              if not (-ncols <= y < ncols):
                  raise H2OValueError(
                      "Column %d does not exist in the training frame"
                      % y
                  )
              y = names[y]
          else:
              if y not in names:
                  raise H2OValueError(
                      "Column %s does not exist in the training frame"
                      % y
                  )
          self.response_column = y
  
      self.fold_column = fold_column
      self.weights_column = weights_column
  
      self.validation_frame = validation_frame
      self.leaderboard_frame = leaderboard_frame
      self.blending_frame = blending_frame
  
      if x is not None:
          assert_is_type(x, list)
          xset = set()
          if is_type(x, int, str):
              x = [x]
          for xi in x:
              if is_type(xi, int):
                  if not (-ncols <= xi < ncols):
                      raise H2OValueError(
                          "Column %d does not exist in the training frame"
                          % xi
                      )
                  xset.add(names[xi])
              else:
                  if xi not in names:
                      raise H2OValueError(
                          "Column %s not in the training frame" % xi
                      )
                  xset.add(xi)
          ignored_columns = set(names) - xset
          for col in [y, fold_column, weights_column]:
              if col is not None and col in ignored_columns:
                  ignored_columns.remove(col)
          if ignored_columns is not None:
              self.input_spec["ignored_columns"] = list(ignored_columns)
  
      def clean_params(params):
          return (
              {
                  k: clean_params(v)
                  for k, v in params.items()
                  if v is not None
              }
              if isinstance(params, dict)
              else H2OEstimator._keyify(params)
          )
  
      automl_build_params = clean_params(
          dict(
              build_control=self.build_control,
              build_models=self.build_models,
              input_spec=self.input_spec,
          )
      )
  
      resp = self._build_resp = h2o.api(
          "POST /99/AutoMLBuilder", json=automl_build_params
      )
      if "job" not in resp:
          raise H2OResponseError(
              "Backend failed to build the AutoML job: {}".format(resp)
          )
  
      if not self.project_name:
          self.project_name = resp["build_control"]["project_name"]
      self.__frozen = True
  
      self._job = H2OJob(resp["job"], "AutoML")
      poll_updates = ft.partial(
          self._poll_training_updates,
          verbosity=self._verbosity,
          state={},
      )
      try:
          self._job.poll(poll_updates=poll_updates)
      finally:
          poll_updates(self._job, 1)
  
      self._fetch()
      return self.leader
  
imports: import functools
  from inspect import getdoc
  import re
  import h2o
  from h2o.base import Keyed
  from h2o.estimators import H2OEstimator
  from h2o.exceptions import H2OResponseError, H2OValueError
  from h2o.frame import H2OFrame
  from h2o.job import H2OJob
  from h2o.utils.compatibility import *
  from h2o.utils.shared_utils import check_id
  from h2o.utils.typechecks import assert_is_type, is_type, numeric
  from ._base import H2OAutoMLBaseMixin, _fetch_state
label_desc: Use image node_id 17 for calling the H2OAutoML obj's underlying member method code with example usage: obj.train(x, y, training_frame, fold_column, weights_column, validation_frame, leaderboard_frame, blending_frame) and returns: self, unknown