# Buggy code
def inverse_transform(self, Y, threshold=None):
    """Transform binary labels back to multi-class labels

    Parameters
    ----------
    Y : numpy array of shape [n_samples, n_classes]
        Target values.

    threshold : float or None
        Threshold used in the binary and multi-label cases.

        Use 0 when:
            - Y contains the output of decision_function (classifier)
        Use 0.5 when:
            - Y contains the output of predict_proba

        If None, the threshold is assumed to be half way between
        neg_label and pos_label.

    Returns
    -------
    y : numpy array of shape (n_samples,) or (n_samples, n_classes)
        Target values. The 2-d matrix should only contain 0 and 1,
        represents multilabel classification.

    Notes
    -----
    In the case when the binary labels are fractional
    (probabilistic), inverse_transform chooses the class with the
    greatest value. Typically, this allows to use the output of a
    linear model's decision_function method directly as the input
    of inverse_transform.
    """
    self._check_fitted()

    if threshold is None:
        half = (self.pos_label - self.neg_label) / 2.0
        threshold = self.neg_label + half

    if self.multilabel_:
        Y = np.array(Y > threshold, dtype=int)
        # Return the predictions in the same format as in fit
        if self.indicator_matrix_:
            # Label indicator matrix format
            return Y
        else:
            # Lists of tuples format
            mlb = MultiLabelBinarizer(classes=self.classes_).fit([])
            return mlb.inverse_transform(Y)

    if len(Y.shape) == 1 or Y.shape[1] == 1:
        y = np.array(Y.ravel() > threshold, dtype=int)

    else:
        y = Y.argmax(axis=1)

    return self.classes_[y]


# Traceback (IndexError)
======================================================================
ERROR: sklearn.tests.test_common.test_regressors_train('RANSACRegressor', <class 'sklearn.linear_model.ransac.RANSACRegr
essor'>, array([[-0.44836249, -0.47282444, -1.20608008, ..., -0.75500806,
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\nose\case.py", line 197, in runTest
self.test(*self.arg)
File "C:\Python27\lib\site-packages\sklearn\tests\test_common.py", line 850, in check_regressors_train
assert_raises(ValueError, regressor.fit, X, y[:-1])
File "C:\Python27\lib\unittest\case.py", line 473, in assertRaises
callableObj(*args, **kwargs)
File "C:\Python27\lib\site-packages\sklearn\linear_model\ransac.py", line 261, in fit
y_subset = y[subset_idxs]
IndexError: index 199 is out of bounds for axis 0 with size 199

# Fixed code
def inverse_transform(self, Y, threshold=None):
    """Transform binary labels back to multi-class labels

    Parameters
    ----------
    Y : numpy array or sparse matrix with shape [n_samples, n_classes]
        Target values. All sparse matrices are converted to CSR before
        inverse transformation.

    threshold : float or None
        Threshold used in the binary and multi-label cases.

        Use 0 when:
            - Y contains the output of decision_function (classifier)
        Use 0.5 when:
            - Y contains the output of predict_proba

        If None, the threshold is assumed to be half way between
        neg_label and pos_label.

    Returns
    -------
    y : numpy array or CSR matrix of shape [n_samples] Target values.

    Notes
    -----
    In the case when the binary labels are fractional
    (probabilistic), inverse_transform chooses the class with the
    greatest value. Typically, this allows to use the output of a
    linear model's decision_function method directly as the input
    of inverse_transform.
    """
    self._check_fitted()

    if threshold is None:
        threshold = (self.pos_label + self.neg_label) / 2.0

    if self.y_type_ == "multiclass":
        y_inv = _inverse_binarize_multiclass(Y, self.classes_)
    else:
        y_inv = _inverse_binarize_thresholding(
            Y, self.y_type_, self.classes_, threshold
        )

    if self.sparse_input_:
        y_inv = sp.csr_matrix(y_inv)
    elif sp.issparse(y_inv):
        y_inv = y_inv.toarray()

    return y_inv