class_docstr: Base class for H2O Estimators.
  
  H2O Estimators implement the following methods for model construction:
  
      - ``start()`` - Top-level user-facing API for asynchronous model build
      - ``join()``  - Top-level user-facing API for blocking on async model build
      - ``train()`` - Top-level user-facing API for model building.
      - ``fit()`` - Used by scikit-learn.
  
  Because H2OEstimator instances are instances of ModelBase, these objects can use the H2O model API.
docstr: Trains H2O model for each segment (subpopulation) of the training dataset.
  
  :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 H2OFrame training_frame: The H2OFrame having the columns indicated by x and y (as well as any
      additional columns specified by fold, offset, and weights).
  :param offset_column: The name or index of the column in training_frame that holds the offsets.
  :param fold_column: The name or index of the column in training_frame that holds the per-row fold
      assignments.
  :param weights_column: The name or index of the column in training_frame that holds the per-row weights.
  :param validation_frame: H2OFrame with validation data to be scored on while training.
  :param float max_runtime_secs: Maximum allowed runtime in seconds for each model training. Use 0 to disable.
      Please note that regardless of how this parameter is set, a model will be built for each input segment.
      This parameter only affects individual model training.
  :param segments: A list of columns to segment-by. H2O will group the training (and validation) dataset
      by the segment-by columns and train a separate model for each segment (group of rows).
      As an alternative to providing a list of columns, users can also supply an explicit enumeration of
      segments to build the models for. This enumeration needs to be represented as H2OFrame.
  :param segment_models_id: Identifier for the returned collection of Segment Models. If not specified
      it will be automatically generated.
  :param parallelism: Level of parallelism of the bulk segment models building, it is the maximum number 
      of models each H2O node will be building in parallel.
  :param bool verbose: Enable to print additional information during model building. Defaults to False.
  
  :examples:
  
  >>> response = "survived"
  >>> titanic = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/titanic.csv")
  >>> titanic[response] = titanic[response].asfactor()
  >>> predictors = ["survived","name","sex","age","sibsp","parch","ticket","fare","cabin"]
  >>> train, valid = titanic.split_frame(ratios=[.8], seed=1234)
  >>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
  >>> titanic_gbm = H2OGradientBoostingEstimator(seed=1234)
  >>> titanic_models = titanic_gbm.train_segments(segments=["pclass"],
  ...                                             x=predictors,
  ...                                             y=response,
  ...                                             training_frame=train,
  ...                                             validation_frame=valid)
  >>> titanic_models.as_frame()
docstr_tok: ["Trains","H2O","model","for","each","segment","(","subpopulation",")","of","the","training","dataset",".",":","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","H2OFrame","training_frame",":","The","H2OFrame","having","the","columns","indicated","by","x","and","y","(","as","well","as","any","additional","columns","specified","by","fold",",","offset",",","and","weights",")",".",":","param","offset_column",":","The","name","or","index","of","the","column","in","training_frame","that","holds","the","offsets",".",":","param","fold_column",":","The","name","or","index","of","the","column","in","training_frame","that","holds","the","per-row","fold","assignments",".",":","param","weights_column",":","The","name","or","index","of","the","column","in","training_frame","that","holds","the","per-row","weights",".",":","param","validation_frame",":","H2OFrame","with","validation","data","to","be","scored","on","while","training",".",":","param","float","max_runtime_secs",":","Maximum","allowed","runtime","in","seconds","for","each","model","training",".","Use","0","to","disable",".","Please","note","that","regardless","of","how","this","parameter","is","set",",","a","model","will","be","built","for","each","input","segment",".","This","parameter","only","affects","individual","model","training",".",":","param","segments",":","A","list","of","columns","to","segment-by",".","H2O","will","group","the","training","(","and","validation",")","dataset","by","the","segment-by","columns","and","train","a","separate","model","for","each","segment","(","group","of","rows",")",".","As","an","alternative","to","providing","a","list","of","columns",",","users","can","also","supply","an","explicit","enumeration","of","segments","to","build","the","models","for",".","This","enumeration","needs","to","be","represented","as","H2OFrame",".",":","param","segment_models_id",":","Identifier","for","the","returned","collection","of","Segment","Models",".","If","not","specified","it","will","be","automatically","generated",".",":","param","parallelism",":","Level","of","parallelism","of","the","bulk","segment","models","building",",","it","is","the","maximum","number","of","models","each","H2O","node","will","be","building","in","parallel",".",":","param","bool","verbose",":","Enable","to","print","additional","information","during","model","building",".","Defaults","to","False",".",":","examples",":",">",">",">","response","=","``","survived","''",">",">",">","titanic","=","h2o.import_file","(","``","https",":","\/\/s3.amazonaws.com\/h2o-public-test-data\/smalldata\/gbm_test\/titanic.csv","''",")",">",">",">","titanic","[","response","]","=","titanic","[","response","]",".asfactor","(",")",">",">",">","predictors","=","[","``","survived","''",",","''","name","''",",","''","sex","''",",","''","age","''",",","''","sibsp","''",",","''","parch","''",",","''","ticket","''",",","''","fare","''",",","''","cabin","''","]",">",">",">","train",",","valid","=","titanic.split_frame","(","ratios=","[",".8","]",",","seed=1234",")",">",">",">","from","h2o.estimators.gbm","import","H2OGradientBoostingEstimator",">",">",">","titanic_gbm","=","H2OGradientBoostingEstimator","(","seed=1234",")",">",">",">","titanic_models","=","titanic_gbm.train_segments","(","segments=","[","``","pclass","''","]",",","...","x=predictors",",","...","y=response",",","...","training_frame=train",",","...","validation_frame=valid",")",">",">",">","titanic_models.as_frame","(",")"]
code: def train_segments(
      self,
      x=None,
      y=None,
      training_frame=None,
      offset_column=None,
      fold_column=None,
      weights_column=None,
      validation_frame=None,
      max_runtime_secs=None,
      ignored_columns=None,
      segments=None,
      segment_models_id=None,
      parallelism=1,
      verbose=False,
  ):
      """
      Trains H2O model for each segment (subpopulation) of the training dataset.
  
      :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 H2OFrame training_frame: The H2OFrame having the columns indicated by x and y (as well as any
          additional columns specified by fold, offset, and weights).
      :param offset_column: The name or index of the column in training_frame that holds the offsets.
      :param fold_column: The name or index of the column in training_frame that holds the per-row fold
          assignments.
      :param weights_column: The name or index of the column in training_frame that holds the per-row weights.
      :param validation_frame: H2OFrame with validation data to be scored on while training.
      :param float max_runtime_secs: Maximum allowed runtime in seconds for each model training. Use 0 to disable.
          Please note that regardless of how this parameter is set, a model will be built for each input segment.
          This parameter only affects individual model training.
      :param segments: A list of columns to segment-by. H2O will group the training (and validation) dataset
          by the segment-by columns and train a separate model for each segment (group of rows).
          As an alternative to providing a list of columns, users can also supply an explicit enumeration of
          segments to build the models for. This enumeration needs to be represented as H2OFrame.
      :param segment_models_id: Identifier for the returned collection of Segment Models. If not specified
          it will be automatically generated.
      :param parallelism: Level of parallelism of the bulk segment models building, it is the maximum number
          of models each H2O node will be building in parallel.
      :param bool verbose: Enable to print additional information during model building. Defaults to False.
  
      :examples:
  
      >>> response = "survived"
      >>> titanic = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/titanic.csv")
      >>> titanic[response] = titanic[response].asfactor()
      >>> predictors = ["survived","name","sex","age","sibsp","parch","ticket","fare","cabin"]
      >>> train, valid = titanic.split_frame(ratios=[.8], seed=1234)
      >>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
      >>> titanic_gbm = H2OGradientBoostingEstimator(seed=1234)
      >>> titanic_models = titanic_gbm.train_segments(segments=["pclass"],
      ...                                             x=predictors,
      ...                                             y=response,
      ...                                             training_frame=train,
      ...                                             validation_frame=valid)
      >>> titanic_models.as_frame()
      """
      assert_is_type(segments, None, H2OFrame, [str])
      assert_is_type(verbose, bool)
      assert_is_type(segment_models_id, None, str)
      assert_is_type(parallelism, int)
  
      if segments is None:
          raise H2OValueError(
              "Parameter segments was not specified. Please provide either a list of columns to "
              "segment-by or an explicit list of segments to build models for."
          )
  
      parms = self._make_parms(
          x=x,
          y=y,
          training_frame=training_frame,
          offset_column=offset_column,
          fold_column=fold_column,
          weights_column=weights_column,
          validation_frame=validation_frame,
          max_runtime_secs=max_runtime_secs,
          ignored_columns=ignored_columns,
          model_id=None,
          verbose=verbose,
      )
  
      if isinstance(segments, H2OFrame):
          parms["segments"] = H2OEstimator._keyify(segments)
      else:
          parms["segment_columns"] = segments
      if segment_models_id:
          parms["segment_models_id"] = segment_models_id
      parms["parallelism"] = parallelism
  
      rest_ver = self._get_rest_version(parms)
      train_segments_response = h2o.api(
          "POST /%d/SegmentModelsBuilders/%s" % (rest_ver, self.algo),
          data=parms,
      )
      job = H2OJob(
          train_segments_response,
          job_type=(self.algo + " Segment Models Build"),
      )
      job.poll()
      return H2OSegmentModels(job.dest_key)
  
imports: from h2o.utils.compatibility import *
  from datetime import datetime
  import inspect
  import warnings
  import h2o
  from h2o.base import Keyed
  from h2o.exceptions import H2OValueError, H2OResponseError
  from h2o.frame import H2OFrame
  from h2o.job import H2OJob
  from h2o.utils.mixin import assign, load_ext, mixin
  from h2o.utils.shared_utils import quoted, LookupSeq
  from h2o.utils.typechecks import assert_is_type, is_type, numeric, FunctionType
  from h2o.model import ModelBase, H2OSegmentModels
  from h2o.model.models import *
  from h2o.model.metrics import *
label_desc: Use image node_id 5 for calling the H2OEstimator obj's underlying member method code with example usage: obj.train_segments(x, y, training_frame, offset_column, fold_column, weights_column, validation_frame, max_runtime_secs, ignored_columns, segments, segment_models_id, parallelism, verbose) and returns: H2OSegmentModels