class_docstr: An AdaBoost regressor.
  
  An AdaBoost [1] regressor is a meta-estimator that begins by fitting a
  regressor on the original dataset and then fits additional copies of the
  regressor on the same dataset but where the weights of instances are
  adjusted according to the error of the current prediction. As such,
  subsequent regressors focus more on difficult cases.
  
  This class implements the algorithm known as AdaBoost.R2 [2].
  
  Read more in the :ref:`User Guide <adaboost>`.
  
  Parameters
  ----------
  base_estimator : object, optional (default=DecisionTreeRegressor)
      The base estimator from which the boosted ensemble is built.
      Support for sample weighting is required.
  
  n_estimators : integer, optional (default=50)
      The maximum number of estimators at which boosting is terminated.
      In case of perfect fit, the learning procedure is stopped early.
  
  learning_rate : float, optional (default=1.)
      Learning rate shrinks the contribution of each regressor by
      ``learning_rate``. There is a trade-off between ``learning_rate`` and
      ``n_estimators``.
  
  loss : {'linear', 'square', 'exponential'}, optional (default='linear')
      The loss function to use when updating the weights after each
      boosting iteration.
  
  random_state : int, RandomState instance or None, optional (default=None)
      If int, random_state is the seed used by the random number generator;
      If RandomState instance, random_state is the random number generator;
      If None, the random number generator is the RandomState instance used
      by `np.random`.
  
  Attributes
  ----------
  estimators_ : list of classifiers
      The collection of fitted sub-estimators.
  
  estimator_weights_ : array of floats
      Weights for each estimator in the boosted ensemble.
  
  estimator_errors_ : array of floats
      Regression error for each estimator in the boosted ensemble.
  
  feature_importances_ : array of shape = [n_features]
      The feature importances if supported by the ``base_estimator``.
  
  See also
  --------
  AdaBoostClassifier, GradientBoostingRegressor, DecisionTreeRegressor
  
  References
  ----------
  .. [1] Y. Freund, R. Schapire, "A Decision-Theoretic Generalization of
         on-Line Learning and an Application to Boosting", 1995.
  
  .. [2] H. Drucker, "Improving Regressors using Boosting Techniques", 1997.
class_docstr_tok: ["An","AdaBoost","regressor",".","An","AdaBoost","[","1","]","regressor","is","a","meta-estimator","that","begins","by","fitting","a","regressor","on","the","original","dataset","and","then","fits","additional","copies","of","the","regressor","on","the","same","dataset","but","where","the","weights","of","instances","are","adjusted","according","to","the","error","of","the","current","prediction",".","As","such",",","subsequent","regressors","focus","more","on","difficult","cases",".","This","class","implements","the","algorithm","known","as","AdaBoost.R2","[","2","]",".","Read","more","in","the",":","ref",":","`","User","Guide","<","adaboost",">","`",".","Parameters","--","--","--","--","--","base_estimator",":","object",",","optional","(","default=DecisionTreeRegressor",")","The","base","estimator","from","which","the","boosted","ensemble","is","built",".","Support","for","sample","weighting","is","required",".","n_estimators",":","integer",",","optional","(","default=50",")","The","maximum","number","of","estimators","at","which","boosting","is","terminated",".","In","case","of","perfect","fit",",","the","learning","procedure","is","stopped","early",".","learning_rate",":","float",",","optional","(","default=1",".",")","Learning","rate","shrinks","the","contribution","of","each","regressor","by","``","learning_rate","``",".","There","is","a","trade-off","between","``","learning_rate","``","and","``","n_estimators","``",".","loss",":","{","'linear","'",",","'square","'",",","'exponential","'","}",",","optional","(","default='linear","'",")","The","loss","function","to","use","when","updating","the","weights","after","each","boosting","iteration",".","random_state",":","int",",","RandomState","instance","or","None",",","optional","(","default=None",")","If","int",",","random_state","is","the","seed","used","by","the","random","number","generator",";","If","RandomState","instance",",","random_state","is","the","random","number","generator",";","If","None",",","the","random","number","generator","is","the","RandomState","instance","used","by","`","np.random","`",".","Attributes","--","--","--","--","--","estimators_",":","list","of","classifiers","The","collection","of","fitted","sub-estimators",".","estimator_weights_",":","array","of","floats","Weights","for","each","estimator","in","the","boosted","ensemble",".","estimator_errors_",":","array","of","floats","Regression","error","for","each","estimator","in","the","boosted","ensemble",".","feature_importances_",":","array","of","shape","=","[","n_features","]","The","feature","importances","if","supported","by","the","``","base_estimator","``",".","See","also","--","--","--","--","AdaBoostClassifier",",","GradientBoostingRegressor",",","DecisionTreeRegressor","References","--","--","--","--","--","..","[","1","]","Y.","Freund",",","R.","Schapire",",","``","A","Decision-Theoretic","Generalization","of","on-Line","Learning","and","an","Application","to","Boosting","''",",","1995",".","..","[","2","]","H.","Drucker",",","``","Improving","Regressors","using","Boosting","Techniques","''",",","1997","."]
docstr: Implement a single boost for regression
  
  Perform a single boost according to the AdaBoost.R2 algorithm and
  return the updated sample weights.
  
  Parameters
  ----------
  iboost : int
      The index of the current boost iteration.
  
  X : {array-like, sparse matrix} of shape = [n_samples, n_features]
      The training input samples. Sparse matrix can be CSC, CSR, COO,
      DOK, or LIL. DOK and LIL are converted to CSR.
  
  y : array-like of shape = [n_samples]
      The target values (class labels in classification, real numbers in
      regression).
  
  sample_weight : array-like of shape = [n_samples]
      The current sample weights.
  
  random_state : numpy.RandomState
      The current random number generator
  
  Returns
  -------
  sample_weight : array-like of shape = [n_samples] or None
      The reweighted sample weights.
      If None then boosting has terminated early.
  
  estimator_weight : float
      The weight for the current boost.
      If None then boosting has terminated early.
  
  estimator_error : float
      The regression error for the current boost.
      If None then boosting has terminated early.
docstr_tok: ["Implement","a","single","boost","for","regression","Perform","a","single","boost","according","to","the","AdaBoost.R2","algorithm","and","return","the","updated","sample","weights",".","Parameters","--","--","--","--","--","iboost",":","int","The","index","of","the","current","boost","iteration",".","X",":","{","array-like",",","sparse","matrix","}","of","shape","=","[","n_samples",",","n_features","]","The","training","input","samples",".","Sparse","matrix","can","be","CSC",",","CSR",",","COO",",","DOK",",","or","LIL",".","DOK","and","LIL","are","converted","to","CSR",".","y",":","array-like","of","shape","=","[","n_samples","]","The","target","values","(","class","labels","in","classification",",","real","numbers","in","regression",")",".","sample_weight",":","array-like","of","shape","=","[","n_samples","]","The","current","sample","weights",".","random_state",":","numpy.RandomState","The","current","random","number","generator","Returns","--","--","--","-","sample_weight",":","array-like","of","shape","=","[","n_samples","]","or","None","The","reweighted","sample","weights",".","If","None","then","boosting","has","terminated","early",".","estimator_weight",":","float","The","weight","for","the","current","boost",".","If","None","then","boosting","has","terminated","early",".","estimator_error",":","float","The","regression","error","for","the","current","boost",".","If","None","then","boosting","has","terminated","early","."]
code: def _boost(self, iboost, X, y, sample_weight, random_state):
      """Implement a single boost for regression
  
      Perform a single boost according to the AdaBoost.R2 algorithm and
      return the updated sample weights.
  
      Parameters
      ----------
      iboost : int
          The index of the current boost iteration.
  
      X : {array-like, sparse matrix} of shape = [n_samples, n_features]
          The training input samples. Sparse matrix can be CSC, CSR, COO,
          DOK, or LIL. DOK and LIL are converted to CSR.
  
      y : array-like of shape = [n_samples]
          The target values (class labels in classification, real numbers in
          regression).
  
      sample_weight : array-like of shape = [n_samples]
          The current sample weights.
  
      random_state : numpy.RandomState
          The current random number generator
  
      Returns
      -------
      sample_weight : array-like of shape = [n_samples] or None
          The reweighted sample weights.
          If None then boosting has terminated early.
  
      estimator_weight : float
          The weight for the current boost.
          If None then boosting has terminated early.
  
      estimator_error : float
          The regression error for the current boost.
          If None then boosting has terminated early.
      """
      estimator = self._make_estimator(random_state=random_state)
  
      # Weighted sampling of the training set with replacement
      # For NumPy >= 1.7.0 use np.random.choice
      cdf = sample_weight.cumsum()
      cdf /= cdf[-1]
      uniform_samples = random_state.random_sample(X.shape[0])
      bootstrap_idx = cdf.searchsorted(uniform_samples, side="right")
      # searchsorted returns a scalar
      bootstrap_idx = np.array(bootstrap_idx, copy=False)
  
      # Fit on the bootstrapped sample and obtain a prediction
      # for all samples in the training set
      estimator.fit(X[bootstrap_idx], y[bootstrap_idx])
      y_predict = estimator.predict(X)
  
      error_vect = np.abs(y_predict - y)
      error_max = error_vect.max()
  
      if error_max != 0.0:
          error_vect /= error_max
  
      if self.loss == "square":
          error_vect **= 2
      elif self.loss == "exponential":
          error_vect = 1.0 - np.exp(-error_vect)
  
      # Calculate the average loss
      estimator_error = (sample_weight * error_vect).sum()
  
      if estimator_error <= 0:
          # Stop if fit is perfect
          return sample_weight, 1.0, 0.0
  
      elif estimator_error >= 0.5:
          # Discard current estimator only if it isn't the only one
          if len(self.estimators_) > 1:
              self.estimators_.pop(-1)
          return None, None, None
  
      beta = estimator_error / (1.0 - estimator_error)
  
      # Boost weight using AdaBoost.R2 alg
      estimator_weight = self.learning_rate * np.log(1.0 / beta)
  
      if not iboost == self.n_estimators - 1:
          sample_weight *= np.power(
              beta, (1.0 - error_vect) * self.learning_rate
          )
  
      return sample_weight, estimator_weight, estimator_error
  
imports: from abc import ABCMeta, abstractmethod
  import numpy
  from numpy.core.umath_tests import inner1d
  from .base import BaseEnsemble
  from ..base import ClassifierMixin, RegressorMixin, is_regressor
  from ..externals import six
  from ..externals.six.moves import zip
  from ..externals.six.moves import xrange
  from .forest import BaseForest
  from ..tree import DecisionTreeClassifier, DecisionTreeRegressor
  from ..tree.tree import BaseDecisionTree
  from ..tree._tree import DTYPE
  from ..utils import check_array, check_X_y, check_random_state
  from ..metrics import accuracy_score, r2_score
  from sklearn.utils.validation import has_fit_parameter, check_is_fitted
label_desc: Use image node_id 4 for calling the AdaBoostRegressor obj's underlying member method code with example usage: obj._boost(iboost, X, y, sample_weight, random_state) and returns: sample_weight,  estimator_weight,  estimator_error, sample_weight,  int,  int, None,  None,  None