# Buggy code
def fit(self, X, y, sample_weight=None):
    """Fit the SVM model according to the given training data.

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape = [n_samples, n_features]
        Training vectors, where n_samples is the number of samples
        and n_features is the number of features.

    y : array-like, shape = [n_samples]
        Target values (class labels in classification, real numbers in
        regression)

    sample_weight : array-like, shape = [n_samples], optional
        Weights applied to individual samples (1. for unweighted).

    Returns
    -------
    self : object
        Returns self.

    Notes
    ------
    If X and y are not C-ordered and contiguous arrays of np.float64 and
    X is not a scipy.sparse.csr_matrix, X and/or y may be copied.

    If X is a dense array, then the other methods will not support sparse
    matrices as input.
    """

    self._sparse = sp.isspmatrix(X) and not self._pairwise

    if self._sparse and self._pairwise:
        raise ValueError(
            "Sparse precomputed kernels are not supported. "
            "Using sparse data and dense kernels is possible "
            "by not using the ``sparse`` parameter"
        )

    X = atleast2d_or_csr(X, dtype=np.float64, order="C")

    if self._impl in ["c_svc", "nu_svc"]:
        # classification
        self.classes_, y = unique(y, return_inverse=True)
        self.class_weight_ = compute_class_weight(self.class_weight, self.classes_, y)
    else:
        self.class_weight_ = np.empty(0)
    if self._impl != "one_class" and len(np.unique(y)) < 2:
        raise ValueError("The number of classes has to be greater than one.")

    y = np.asarray(y, dtype=np.float64, order="C")

    sample_weight = np.asarray(
        [] if sample_weight is None else sample_weight, dtype=np.float64
    )
    solver_type = LIBSVM_IMPL.index(self._impl)

    # input validation
    if solver_type != 2 and X.shape[0] != y.shape[0]:
        raise ValueError(
            "X and y have incompatible shapes.\n"
            + "X has %s samples, but y has %s." % (X.shape[0], y.shape[0])
        )

    if self.kernel == "precomputed" and X.shape[0] != X.shape[1]:
        raise ValueError("X.shape[0] should be equal to X.shape[1]")

    if sample_weight.shape[0] > 0 and sample_weight.shape[0] != X.shape[0]:
        raise ValueError(
            "sample_weight and X have incompatible shapes:"
            "%r vs %r\n"
            "Note: Sparse matrices cannot be indexed w/"
            "boolean masks (use `indices=True` in CV)." % (sample_weight.shape, X.shape)
        )

    if (self.kernel in ["poly", "rbf"]) and (self.gamma == 0):
        # if custom gamma is not provided ...
        self._gamma = 1.0 / X.shape[1]
    else:
        self._gamma = self.gamma

    kernel = self.kernel
    if callable(kernel):
        kernel = "precomputed"

    fit = self._sparse_fit if self._sparse else self._dense_fit
    if self.verbose:  # pragma: no cover
        print("[LibSVM]", end="")
    fit(X, y, sample_weight, solver_type, kernel)

    self.shape_fit_ = X.shape

    # In binary case, we need to flip the sign of coef, intercept and
    # decision function. Use self._intercept_ internally.
    self._intercept_ = self.intercept_.copy()
    if self._impl in ["c_svc", "nu_svc"] and len(self.classes_) == 2:
        self.intercept_ *= -1
    return self


# Traceback (ValueError)
$ nosetests sklearn/ensemble/tests/test_weight_boosting.py
.........E
======================================================================
ERROR: Test different base estimators.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/scratch/apps/src/scikit-learn/sklearn/ensemble/tests/test_weight_boosting.py", line 213, in test_base_estimator
clf.fit(X, y)
File "/scratch/apps/src/scikit-learn/sklearn/ensemble/weight_boosting.py", line 911, in fit
return super(AdaBoostRegressor, self).fit(X, y, sample_weight)
File "/scratch/apps/src/scikit-learn/sklearn/ensemble/weight_boosting.py", line 126, in fit
X_argsorted=X_argsorted)
File "/scratch/apps/src/scikit-learn/sklearn/ensemble/weight_boosting.py", line 972, in _boost
estimator.fit(X[bootstrap_idx], y[bootstrap_idx])
File "/scratch/apps/src/scikit-learn/sklearn/svm/base.py", line 143, in fit
raise ValueError("The number of classes has to be greater than"
ValueError: The number of classes has to be greater than one.

----------------------------------------------------------------------
Ran 10 tests in 0.893s

FAILED (errors=1)

# Fixed code
def fit(self, X, y, sample_weight=None):
    """Fit the SVM model according to the given training data.

    Parameters
    ----------
    X : {array-like, sparse matrix}, shape = [n_samples, n_features]
        Training vectors, where n_samples is the number of samples
        and n_features is the number of features.

    y : array-like, shape = [n_samples]
        Target values (class labels in classification, real numbers in
        regression)

    sample_weight : array-like, shape = [n_samples], optional
        Weights applied to individual samples (1. for unweighted).

    Returns
    -------
    self : object
        Returns self.

    Notes
    ------
    If X and y are not C-ordered and contiguous arrays of np.float64 and
    X is not a scipy.sparse.csr_matrix, X and/or y may be copied.

    If X is a dense array, then the other methods will not support sparse
    matrices as input.
    """

    self._sparse = sp.isspmatrix(X) and not self._pairwise

    if self._sparse and self._pairwise:
        raise ValueError(
            "Sparse precomputed kernels are not supported. "
            "Using sparse data and dense kernels is possible "
            "by not using the ``sparse`` parameter"
        )

    X = atleast2d_or_csr(X, dtype=np.float64, order="C")
    y = self._validate_targets(y)

    sample_weight = np.asarray(
        [] if sample_weight is None else sample_weight, dtype=np.float64
    )
    solver_type = LIBSVM_IMPL.index(self._impl)

    # input validation
    if solver_type != 2 and X.shape[0] != y.shape[0]:
        raise ValueError(
            "X and y have incompatible shapes.\n"
            + "X has %s samples, but y has %s." % (X.shape[0], y.shape[0])
        )

    if self.kernel == "precomputed" and X.shape[0] != X.shape[1]:
        raise ValueError("X.shape[0] should be equal to X.shape[1]")

    if sample_weight.shape[0] > 0 and sample_weight.shape[0] != X.shape[0]:
        raise ValueError(
            "sample_weight and X have incompatible shapes:"
            "%r vs %r\n"
            "Note: Sparse matrices cannot be indexed w/"
            "boolean masks (use `indices=True` in CV)." % (sample_weight.shape, X.shape)
        )

    if (self.kernel in ["poly", "rbf"]) and (self.gamma == 0):
        # if custom gamma is not provided ...
        self._gamma = 1.0 / X.shape[1]
    else:
        self._gamma = self.gamma

    kernel = self.kernel
    if callable(kernel):
        kernel = "precomputed"

    fit = self._sparse_fit if self._sparse else self._dense_fit
    if self.verbose:  # pragma: no cover
        print("[LibSVM]", end="")
    fit(X, y, sample_weight, solver_type, kernel)

    self.shape_fit_ = X.shape

    # In binary case, we need to flip the sign of coef, intercept and
    # decision function. Use self._intercept_ internally.
    self._intercept_ = self.intercept_.copy()
    if self._impl in ["c_svc", "nu_svc"] and len(self.classes_) == 2:
        self.intercept_ *= -1
    return self