class_docstr: Stack of estimators with a final regressor.
  
  Stacked generalization consists in stacking the output of individual
  estimator and use a regressor to compute the final prediction. Stacking
  allows to use the strength of each individual estimator by using their
  output as input of a final estimator.
  
  Note that `estimators_` are fitted on the full `X` while `final_estimator_`
  is trained using cross-validated predictions of the base estimators using
  `cross_val_predict`.
  
  Read more in the :ref:`User Guide <stacking>`.
  
  .. versionadded:: 0.22
  
  Parameters
  ----------
  estimators : list of (str, estimator)
      Base estimators which will be stacked together. Each element of the
      list is defined as a tuple of string (i.e. name) and an estimator
      instance. An estimator can be set to 'drop' using `set_params`.
  
  final_estimator : estimator, default=None
      A regressor which will be used to combine the base estimators.
      The default regressor is a :class:`~sklearn.linear_model.RidgeCV`.
  
  cv : int, cross-validation generator, iterable, or "prefit", default=None
      Determines the cross-validation splitting strategy used in
      `cross_val_predict` to train `final_estimator`. Possible inputs for
      cv are:
  
      * None, to use the default 5-fold cross validation,
      * integer, to specify the number of folds in a (Stratified) KFold,
      * An object to be used as a cross-validation generator,
      * An iterable yielding train, test splits.
      * "prefit" to assume the `estimators` are prefit, and skip cross validation
  
      For integer/None inputs, if the estimator is a classifier and y is
      either binary or multiclass,
      :class:`~sklearn.model_selection.StratifiedKFold` is used.
      In all other cases, :class:`~sklearn.model_selection.KFold` is used.
      These splitters are instantiated with `shuffle=False` so the splits
      will be the same across calls.
  
      Refer :ref:`User Guide <cross_validation>` for the various
      cross-validation strategies that can be used here.
  
      If "prefit" is passed, it is assumed that all `estimators` have
      been fitted already. The `final_estimator_` is trained on the `estimators`
      predictions on the full training set and are **not** cross validated
      predictions. Please note that if the models have been trained on the same
      data to train the stacking model, there is a very high risk of overfitting.
  
      .. versionadded:: 1.1
          The 'prefit' option was added in 1.1
  
      .. note::
         A larger number of split will provide no benefits if the number
         of training samples is large enough. Indeed, the training time
         will increase. ``cv`` is not used for model evaluation but for
         prediction.
  
  n_jobs : int, default=None
      The number of jobs to run in parallel for `fit` of all `estimators`.
      `None` means 1 unless in a `joblib.parallel_backend` context. -1 means
      using all processors. See Glossary for more details.
  
  passthrough : bool, default=False
      When False, only the predictions of estimators will be used as
      training data for `final_estimator`. When True, the
      `final_estimator` is trained on the predictions as well as the
      original training data.
  
  verbose : int, default=0
      Verbosity level.
  
  Attributes
  ----------
  estimators_ : list of estimator
      The elements of the `estimators` parameter, having been fitted on the
      training data. If an estimator has been set to `'drop'`, it
      will not appear in `estimators_`. When `cv="prefit"`, `estimators_`
      is set to `estimators` and is not fitted again.
  
  named_estimators_ : :class:`~sklearn.utils.Bunch`
      Attribute to access any fitted sub-estimators by name.
  
  n_features_in_ : int
      Number of features seen during :term:`fit`. Only defined if the
      underlying regressor exposes such an attribute when fit.
  
      .. versionadded:: 0.24
  
  feature_names_in_ : ndarray of shape (`n_features_in_`,)
      Names of features seen during :term:`fit`. Only defined if the
      underlying estimators expose such an attribute when fit.
  
      .. versionadded:: 1.0
  
  final_estimator_ : estimator
      The regressor to stacked the base estimators fitted.
  
  stack_method_ : list of str
      The method used by each base estimator.
  
  See Also
  --------
  StackingClassifier : Stack of estimators with a final classifier.
  
  References
  ----------
  .. [1] Wolpert, David H. "Stacked generalization." Neural networks 5.2
     (1992): 241-259.
  
  Examples
  --------
  >>> from sklearn.datasets import load_diabetes
  >>> from sklearn.linear_model import RidgeCV
  >>> from sklearn.svm import LinearSVR
  >>> from sklearn.ensemble import RandomForestRegressor
  >>> from sklearn.ensemble import StackingRegressor
  >>> X, y = load_diabetes(return_X_y=True)
  >>> estimators = [
  ...     ('lr', RidgeCV()),
  ...     ('svr', LinearSVR(dual="auto", random_state=42))
  ... ]
  >>> reg = StackingRegressor(
  ...     estimators=estimators,
  ...     final_estimator=RandomForestRegressor(n_estimators=10,
  ...                                           random_state=42)
  ... )
  >>> from sklearn.model_selection import train_test_split
  >>> X_train, X_test, y_train, y_test = train_test_split(
  ...     X, y, random_state=42
  ... )
  >>> reg.fit(X_train, y_train).score(X_test, y_test)
  0.3...
class_docstr_tok: ["Stack","of","estimators","with","a","final","regressor",".","Stacked","generalization","consists","in","stacking","the","output","of","individual","estimator","and","use","a","regressor","to","compute","the","final","prediction",".","Stacking","allows","to","use","the","strength","of","each","individual","estimator","by","using","their","output","as","input","of","a","final","estimator",".","Note","that","`","estimators_","`","are","fitted","on","the","full","`","X","`","while","`","final_estimator_","`","is","trained","using","cross-validated","predictions","of","the","base","estimators","using","`","cross_val_predict","`",".","Read","more","in","the",":","ref",":","`","User","Guide","<","stacking",">","`",".","..","versionadded",":",":","0.22","Parameters","--","--","--","--","--","estimators",":","list","of","(","str",",","estimator",")","Base","estimators","which","will","be","stacked","together",".","Each","element","of","the","list","is","defined","as","a","tuple","of","string","(","i.e",".","name",")","and","an","estimator","instance",".","An","estimator","can","be","set","to","'drop","'","using","`","set_params","`",".","final_estimator",":","estimator",",","default=None","A","regressor","which","will","be","used","to","combine","the","base","estimators",".","The","default","regressor","is","a",":","class",":","`","~sklearn.linear_model.RidgeCV","`",".","cv",":","int",",","cross-validation","generator",",","iterable",",","or","``","prefit","''",",","default=None","Determines","the","cross-validation","splitting","strategy","used","in","`","cross_val_predict","`","to","train","`","final_estimator","`",".","Possible","inputs","for","cv","are",":","*","None",",","to","use","the","default","5-fold","cross","validation",",","*","integer",",","to","specify","the","number","of","folds","in","a","(","Stratified",")","KFold",",","*","An","object","to","be","used","as","a","cross-validation","generator",",","*","An","iterable","yielding","train",",","test","splits",".","*","``","prefit","''","to","assume","the","`","estimators","`","are","prefit",",","and","skip","cross","validation","For","integer\/None","inputs",",","if","the","estimator","is","a","classifier","and","y","is","either","binary","or","multiclass",",",":","class",":","`","~sklearn.model_selection.StratifiedKFold","`","is","used",".","In","all","other","cases",",",":","class",":","`","~sklearn.model_selection.KFold","`","is","used",".","These","splitters","are","instantiated","with","`","shuffle=False","`","so","the","splits","will","be","the","same","across","calls",".","Refer",":","ref",":","`","User","Guide","<","cross_validation",">","`","for","the","various","cross-validation","strategies","that","can","be","used","here",".","If","``","prefit","''","is","passed",",","it","is","assumed","that","all","`","estimators","`","have","been","fitted","already",".","The","`","final_estimator_","`","is","trained","on","the","`","estimators","`","predictions","on","the","full","training","set","and","are","*","*","not","*","*","cross","validated","predictions",".","Please","note","that","if","the","models","have","been","trained","on","the","same","data","to","train","the","stacking","model",",","there","is","a","very","high","risk","of","overfitting",".","..","versionadded",":",":","1.1","The","'prefit","'","option","was","added","in","1.1","..","note",":",":","A","larger","number","of","split","will","provide","no","benefits","if","the","number","of","training","samples","is","large","enough",".","Indeed",",","the","training","time","will","increase",".","``","cv","``","is","not","used","for","model","evaluation","but","for","prediction",".","n_jobs",":","int",",","default=None","The","number","of","jobs","to","run","in","parallel","for","`","fit","`","of","all","`","estimators","`",".","`","None","`","means","1","unless","in","a","`","joblib.parallel_backend","`","context",".","-1","means","using","all","processors",".","See","Glossary","for","more","details",".","passthrough",":","bool",",","default=False","When","False",",","only","the","predictions","of","estimators","will","be","used","as","training","data","for","`","final_estimator","`",".","When","True",",","the","`","final_estimator","`","is","trained","on","the","predictions","as","well","as","the","original","training","data",".","verbose",":","int",",","default=0","Verbosity","level",".","Attributes","--","--","--","--","--","estimators_",":","list","of","estimator","The","elements","of","the","`","estimators","`","parameter",",","having","been","fitted","on","the","training","data",".","If","an","estimator","has","been","set","to","`","'drop","'","`",",","it","will","not","appear","in","`","estimators_","`",".","When","`","cv=","''","prefit","''","`",",","`","estimators_","`","is","set","to","`","estimators","`","and","is","not","fitted","again",".","named_estimators_",":",":","class",":","`","~sklearn.utils.Bunch","`","Attribute","to","access","any","fitted","sub-estimators","by","name",".","n_features_in_",":","int","Number","of","features","seen","during",":","term",":","`","fit","`",".","Only","defined","if","the","underlying","regressor","exposes","such","an","attribute","when","fit",".","..","versionadded",":",":","0.24","feature_names_in_",":","ndarray","of","shape","(","`","n_features_in_","`",",",")","Names","of","features","seen","during",":","term",":","`","fit","`",".","Only","defined","if","the","underlying","estimators","expose","such","an","attribute","when","fit",".","..","versionadded",":",":","1.0","final_estimator_",":","estimator","The","regressor","to","stacked","the","base","estimators","fitted",".","stack_method_",":","list","of","str","The","method","used","by","each","base","estimator",".","See","Also","--","--","--","--","StackingClassifier",":","Stack","of","estimators","with","a","final","classifier",".","References","--","--","--","--","--","..","[","1","]","Wolpert",",","David","H.","``","Stacked","generalization",".","''","Neural","networks","5.2","(","1992",")",":","241-259",".","Examples","--","--","--","--",">",">",">","from","sklearn.datasets","import","load_diabetes",">",">",">","from","sklearn.linear_model","import","RidgeCV",">",">",">","from","sklearn.svm","import","LinearSVR",">",">",">","from","sklearn.ensemble","import","RandomForestRegressor",">",">",">","from","sklearn.ensemble","import","StackingRegressor",">",">",">","X",",","y","=","load_diabetes","(","return_X_y=True",")",">",">",">","estimators","=","[","...","(","'lr","'",",","RidgeCV","(",")",")",",","...","(","'svr","'",",","LinearSVR","(","dual=","''","auto","''",",","random_state=42",")",")","...","]",">",">",">","reg","=","StackingRegressor","(","...","estimators=estimators",",","...","final_estimator=RandomForestRegressor","(","n_estimators=10",",","...","random_state=42",")","...",")",">",">",">","from","sklearn.model_selection","import","train_test_split",">",">",">","X_train",",","X_test",",","y_train",",","y_test","=","train_test_split","(","...","X",",","y",",","random_state=42","...",")",">",">",">","reg.fit","(","X_train",",","y_train",")",".score","(","X_test",",","y_test",")","0.3","..."]
code: def _validate_final_estimator(self):
      self._clone_final_estimator(default=RidgeCV())
      if not is_regressor(self.final_estimator_):
          raise ValueError(
              "'final_estimator' parameter should be a regressor. Got {}".format(
                  self.final_estimator_
              )
          )
  
imports: from abc import ABCMeta, abstractmethod
  from copy import deepcopy
  from numbers import Integral
  import numpy
  import scipy.sparse
  from ..base import ClassifierMixin, RegressorMixin, TransformerMixin, _fit_context, clone, is_classifier, is_regressor
  from ..exceptions import NotFittedError
  from ..linear_model import LogisticRegression, RidgeCV
  from ..model_selection import check_cv, cross_val_predict
  from ..preprocessing import LabelEncoder
  from ..utils import Bunch
  from ..utils._estimator_html_repr import _VisualBlock
  from ..utils._param_validation import HasMethods, StrOptions
  from ..utils.metadata_routing import _raise_for_unsupported_routing, _RoutingNotSupportedMixin
  from ..utils.metaestimators import available_if
  from ..utils.multiclass import check_classification_targets, type_of_target
  from ..utils.parallel import Parallel, delayed
  from ..utils.validation import _check_feature_names_in, _check_response_method, check_is_fitted, column_or_1d
  from ._base import _BaseHeterogeneousEnsemble, _fit_single_estimator
label_desc: Use image node_id 2 for calling the StackingRegressor obj's underlying member method code with example usage: obj._validate_final_estimator() without return types