class_docstr: Stacked Ensemble
  
  Builds a stacked ensemble (aka "super learner") machine learning method that uses two
  or more H2O learning algorithms to improve predictive performance. It is a loss-based
  supervised learning method that finds the optimal combination of a collection of prediction
  algorithms.This method supports regression and binary classification.
  
  :examples:
  
  >>> import h2o
  >>> h2o.init()
  >>> from h2o.estimators.random_forest import H2ORandomForestEstimator
  >>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
  >>> from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
  >>> col_types = ["numeric", "numeric", "numeric", "enum",
  ...              "enum", "numeric", "numeric", "numeric", "numeric"]
  >>> data = h2o.import_file("http://h2o-public-test-data.s3.amazonaws.com/smalldata/prostate/prostate.csv", col_types=col_types)
  >>> train, test = data.split_frame(ratios=[.8], seed=1)
  >>> x = ["CAPSULE","GLEASON","RACE","DPROS","DCAPS","PSA","VOL"]
  >>> y = "AGE"
  >>> nfolds = 5
  >>> gbm = H2OGradientBoostingEstimator(nfolds=nfolds,
  ...                                    fold_assignment="Modulo",
  ...                                    keep_cross_validation_predictions=True)
  >>> gbm.train(x=x, y=y, training_frame=train)
  >>> rf = H2ORandomForestEstimator(nfolds=nfolds,
  ...                               fold_assignment="Modulo",
  ...                               keep_cross_validation_predictions=True)
  >>> rf.train(x=x, y=y, training_frame=train)
  >>> stack = H2OStackedEnsembleEstimator(model_id="ensemble",
  ...                                     training_frame=train,
  ...                                     validation_frame=test,
  ...                                     base_models=[gbm.model_id, rf.model_id])
  >>> stack.train(x=x, y=y, training_frame=train, validation_frame=test)
  >>> stack.model_performance()
class_docstr_tok: ["Stacked","Ensemble","Builds","a","stacked","ensemble","(","aka","``","super","learner","''",")","machine","learning","method","that","uses","two","or","more","H2O","learning","algorithms","to","improve","predictive","performance",".","It","is","a","loss-based","supervised","learning","method","that","finds","the","optimal","combination","of","a","collection","of","prediction","algorithms.This","method","supports","regression","and","binary","classification",".",":","examples",":",">",">",">","import","h2o",">",">",">","h2o.init","(",")",">",">",">","from","h2o.estimators.random_forest","import","H2ORandomForestEstimator",">",">",">","from","h2o.estimators.gbm","import","H2OGradientBoostingEstimator",">",">",">","from","h2o.estimators.stackedensemble","import","H2OStackedEnsembleEstimator",">",">",">","col_types","=","[","``","numeric","''",",","``","numeric","''",",","``","numeric","''",",","``","enum","''",",","...","``","enum","''",",","``","numeric","''",",","``","numeric","''",",","``","numeric","''",",","``","numeric","''","]",">",">",">","data","=","h2o.import_file","(","``","http",":","\/\/h2o-public-test-data.s3.amazonaws.com\/smalldata\/prostate\/prostate.csv","''",",","col_types=col_types",")",">",">",">","train",",","test","=","data.split_frame","(","ratios=","[",".8","]",",","seed=1",")",">",">",">","x","=","[","``","CAPSULE","''",",","''","GLEASON","''",",","''","RACE","''",",","''","DPROS","''",",","''","DCAPS","''",",","''","PSA","''",",","''","VOL","''","]",">",">",">","y","=","``","AGE","''",">",">",">","nfolds","=","5",">",">",">","gbm","=","H2OGradientBoostingEstimator","(","nfolds=nfolds",",","...","fold_assignment=","''","Modulo","''",",","...","keep_cross_validation_predictions=True",")",">",">",">","gbm.train","(","x=x",",","y=y",",","training_frame=train",")",">",">",">","rf","=","H2ORandomForestEstimator","(","nfolds=nfolds",",","...","fold_assignment=","''","Modulo","''",",","...","keep_cross_validation_predictions=True",")",">",">",">","rf.train","(","x=x",",","y=y",",","training_frame=train",")",">",">",">","stack","=","H2OStackedEnsembleEstimator","(","model_id=","''","ensemble","''",",","...","training_frame=train",",","...","validation_frame=test",",","...","base_models=","[","gbm.model_id",",","rf.model_id","]",")",">",">",">","stack.train","(","x=x",",","y=y",",","training_frame=train",",","validation_frame=test",")",">",">",">","stack.model_performance","(",")"]
docstr: Type of algorithm to use as the metalearner. Options include 'AUTO' (GLM with non negative weights; if
  validation_frame is present, a lambda search is performed), 'deeplearning' (Deep Learning with default
  parameters), 'drf' (Random Forest with default parameters), 'gbm' (GBM with default parameters), 'glm' (GLM with
  default parameters), 'naivebayes' (NaiveBayes with default parameters), or 'xgboost' (if available, XGBoost with
  default parameters).
  
  Type: ``Literal["auto", "deeplearning", "drf", "gbm", "glm", "naivebayes", "xgboost"]``, defaults to ``"auto"``.
  
  :examples:
  
  >>> from h2o.estimators.random_forest import H2ORandomForestEstimator
  >>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
  >>> from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
  >>> higgs = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/testng/higgs_train_5k.csv")
  >>> train, blend = higgs.split_frame(ratios = [.8], seed = 1234)
  >>> x = train.columns
  >>> y = "response"
  >>> x.remove(y)
  >>> train[y] = train[y].asfactor()
  >>> blend[y] = blend[y].asfactor()
  >>> nfolds = 3
  >>> my_gbm = H2OGradientBoostingEstimator(distribution="bernoulli",
  ...                                       ntrees=1,
  ...                                       nfolds=nfolds,
  ...                                       fold_assignment="Modulo",
  ...                                       keep_cross_validation_predictions=True,
  ...                                       seed=1)
  >>> my_gbm.train(x=x, y=y, training_frame=train)
  >>> my_rf = H2ORandomForestEstimator(ntrees=50,
  ...                                  nfolds=nfolds,
  ...                                  fold_assignment="Modulo",
  ...                                  keep_cross_validation_predictions=True,
  ...                                  seed=1)
  >>> my_rf.train(x=x, y=y, training_frame=train)
  >>> stack_blend = H2OStackedEnsembleEstimator(base_models=[my_gbm, my_rf],
  ...                                           seed=1,
  ...                                           metalearner_algorithm="gbm")
  >>> stack_blend.train(x=x, y=y, training_frame=train, blending_frame=blend)
  >>> stack_blend.model_performance(blend).auc()
code: def metalearner_algorithm(self):
      """
      Type of algorithm to use as the metalearner. Options include 'AUTO' (GLM with non negative weights; if
      validation_frame is present, a lambda search is performed), 'deeplearning' (Deep Learning with default
      parameters), 'drf' (Random Forest with default parameters), 'gbm' (GBM with default parameters), 'glm' (GLM with
      default parameters), 'naivebayes' (NaiveBayes with default parameters), or 'xgboost' (if available, XGBoost with
      default parameters).
  
      Type: ``Literal["auto", "deeplearning", "drf", "gbm", "glm", "naivebayes", "xgboost"]``, defaults to ``"auto"``.
  
      :examples:
  
      >>> from h2o.estimators.random_forest import H2ORandomForestEstimator
      >>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
      >>> from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
      >>> higgs = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/testng/higgs_train_5k.csv")
      >>> train, blend = higgs.split_frame(ratios = [.8], seed = 1234)
      >>> x = train.columns
      >>> y = "response"
      >>> x.remove(y)
      >>> train[y] = train[y].asfactor()
      >>> blend[y] = blend[y].asfactor()
      >>> nfolds = 3
      >>> my_gbm = H2OGradientBoostingEstimator(distribution="bernoulli",
      ...                                       ntrees=1,
      ...                                       nfolds=nfolds,
      ...                                       fold_assignment="Modulo",
      ...                                       keep_cross_validation_predictions=True,
      ...                                       seed=1)
      >>> my_gbm.train(x=x, y=y, training_frame=train)
      >>> my_rf = H2ORandomForestEstimator(ntrees=50,
      ...                                  nfolds=nfolds,
      ...                                  fold_assignment="Modulo",
      ...                                  keep_cross_validation_predictions=True,
      ...                                  seed=1)
      >>> my_rf.train(x=x, y=y, training_frame=train)
      >>> stack_blend = H2OStackedEnsembleEstimator(base_models=[my_gbm, my_rf],
      ...                                           seed=1,
      ...                                           metalearner_algorithm="gbm")
      >>> stack_blend.train(x=x, y=y, training_frame=train, blending_frame=blend)
      >>> stack_blend.model_performance(blend).auc()
      """
      return self._parms.get("metalearner_algorithm")
  
imports: import ast
  import json
  import warnings
  import h2o
  from h2o.base import Keyed
  from h2o.exceptions import H2OResponseError, H2ODeprecationWarning
  from h2o.grid import H2OGridSearch
  from h2o.job import H2OJob
  from h2o.utils.shared_utils import quoted
  from h2o.utils.typechecks import is_type
  from h2o.estimators.estimator_base import H2OEstimator
  from h2o.exceptions import H2OValueError
  from h2o.frame import H2OFrame
  from h2o.utils.typechecks import assert_is_type, Enum, numeric
label_desc: Use image node_id 12 for calling the H2OStackedEnsembleEstimator obj's underlying member method code with example usage: obj.metalearner_algorithm() and returns: self