'Build a boosted classifier/regressor from the training set (X, y).
Parameters
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. COO, DOK, and LIL are converted to CSR. The dtype is
forced to DTYPE from tree._tree if the base classifier of this
ensemble weighted boosting classifier is a tree or forest.
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], optional
Sample weights. If None, the sample weights are initialized to
1 / n_samples.
Returns
self : object
Returns self.'

def fit(self, X, y, sample_weight=None):

    if (self.learning_rate <= 0):
        raise ValueError('learning_rate    must    be    greater    than    zero')
    if ((self.base_estimator is None) or isinstance(self.base_estimator, (BaseDecisionTree, BaseForest))):
        dtype = DTYPE
        accept_sparse = 'csc'
    else:
        dtype = None
        accept_sparse = ['csr', 'csc']
    (X, y) = check_X_y(X, y, accept_sparse=accept_sparse, dtype=dtype, y_numeric=is_regressor(self))
    if (sample_weight is None):
        sample_weight = np.empty(X.shape[0], dtype=np.float64)
        sample_weight[:] = (1.0 / X.shape[0])
    else:
        sample_weight = check_array(sample_weight, ensure_2d=False)
        sample_weight = (sample_weight / sample_weight.sum(dtype=np.float64))
        if (sample_weight.sum() <= 0):
            raise ValueError('Attempting    to    fit    with    a    non-positive    weighted    number    of    samples.')
    self._validate_estimator()
    self.estimators_ = []
    self.estimator_weights_ = np.zeros(self.n_estimators, dtype=np.float64)
    self.estimator_errors_ = np.ones(self.n_estimators, dtype=np.float64)
    random_state = check_random_state(self.random_state)
    for iboost in range(self.n_estimators):
        (sample_weight, estimator_weight, estimator_error) = self._boost(iboost, X, y, sample_weight, random_state)
        if (sample_weight is None):
            break
        self.estimator_weights_[iboost] = estimator_weight
        self.estimator_errors_[iboost] = estimator_error
        if (estimator_error == 0):
            break
        sample_weight_sum = np.sum(sample_weight)
        if (sample_weight_sum <= 0):
            break
        if (iboost < (self.n_estimators - 1)):
            sample_weight /= sample_weight_sum
    return self
