# Buggy code
def check_target_type(y, indicate_one_vs_all=False):
    """Check the target types to be conform to the current samplers.

    The current samplers should be compatible with ``'binary'``,
    ``'multilabel-indicator'`` and ``'multiclass'`` targets only.

    Parameters
    ----------
    y : ndarray,
        The array containing the target.

    indicate_one_vs_all : bool, optional
        Either to indicate if the targets are encoded in a one-vs-all fashion.

    Returns
    -------
    y : ndarray,
        The returned target.

    is_one_vs_all : bool, optional
        Indicate if the target was originally encoded in a one-vs-all fashion.
        Only returned if ``indicate_multilabel=True``.

    """
    type_y = type_of_target(y)
    if type_y == "multilabel-indicator":
        if np.any(y.sum(axis=1) > 1):
            raise ValueError(
                "Imbalanced-learn currently supports binary, multiclass and "
                "binarized encoded multiclasss targets. Multilabel and "
                "multioutput targets are not supported."
            )
        y = y.argmax(axis=1)

    return (y, type_y == "multilabel-indicator") if indicate_one_vs_all else y


# Traceback (TypeError)
TypeError                                 Traceback (most recent call last)
<ipython-input-51-da2a32d7cb52> in <module>()
----> pipe.fit(X_train, y_train)

10 frames
/usr/local/lib/python3.6/dist-packages/sklearn/model_selection/_search.py in fit(self, X, y, groups, **fit_params)
737             refit_start_time = time.time()
738             if y is not None:
--> 739                 self.best_estimator_.fit(X, y, **fit_params)
740             else:
741                 self.best_estimator_.fit(X, **fit_params)

/usr/local/lib/python3.6/dist-packages/imblearn/pipeline.py in fit(self, X, y, **fit_params)
285
286         """
--> 287         Xt, yt, fit_params = self._fit(X, y, **fit_params)
288         with _print_elapsed_time('Pipeline',
289                                  self._log_message(len(self.steps) - 1)):

/usr/local/lib/python3.6/dist-packages/imblearn/pipeline.py in _fit(self, X, y, **fit_params)
247                     message_clsname='Pipeline',
248                     message=self._log_message(step_idx),
--> 249                     **fit_params_steps[name]
250                 )
251             # Replace the transformer of the step with the fitted

/usr/local/lib/python3.6/dist-packages/joblib/memory.py in __call__(self, *args, **kwargs)
566
567     def __call__(self, *args, **kwargs):
--> 568         return self._cached_call(args, kwargs)[0]
569
570     def __getstate__(self):

/usr/local/lib/python3.6/dist-packages/joblib/memory.py in _cached_call(self, args, kwargs, shelving)
532
533         if must_call:
--> 534             out, metadata = self.call(*args, **kwargs)
535             if self.mmap_mode is not None:
536                 # Memmap the output at the first call to be consistent with

/usr/local/lib/python3.6/dist-packages/joblib/memory.py in call(self, *args, **kwargs)
732         if self._verbose > 0:
733             print(format_call(self.func, args, kwargs))
--> 734         output = self.func(*args, **kwargs)
735         self.store_backend.dump_item(
736             [func_id, args_id], output, verbose=self._verbose)

/usr/local/lib/python3.6/dist-packages/imblearn/pipeline.py in _fit_resample_one(sampler, X, y, message_clsname, message, **fit_params)
412                       **fit_params):
413     with _print_elapsed_time(message_clsname, message):
--> 414         X_res, y_res = sampler.fit_resample(X, y, **fit_params)
415
416         return X_res, y_res, sampler

/usr/local/lib/python3.6/dist-packages/imblearn/base.py in fit_resample(self, X, y)
79         )
80
---> 81         output = self._fit_resample(X, y)
82
83         if self._X_columns is not None or self._y_name is not None:

/usr/local/lib/python3.6/dist-packages/imblearn/over_sampling/_random_over_sampler.py in _fit_resample(self, X, y)
102     def _fit_resample(self, X, y):
103         random_state = check_random_state(self.random_state)
--> 104         target_stats = Counter(y)
105
106         sample_indices = range(X.shape[0])

/usr/lib/python3.6/collections/__init__.py in __init__(*args, **kwds)
533             raise TypeError('expected at most 1 arguments, got %d' % len(args))
534         super(Counter, self).__init__()
--> 535         self.update(*args, **kwds)
536
537     def __missing__(self, key):

/usr/lib/python3.6/collections/__init__.py in update(*args, **kwds)
620                     super(Counter, self).update(iterable) # fast path when counter is empty
621             else:
--> 622                 _count_elements(self, iterable)
623         if kwds:
624             self.update(kwds)

TypeError: unhashable type: 'numpy.ndarray'

# Fixed code
def check_target_type(y, indicate_one_vs_all=False):
    """Check the target types to be conform to the current samplers.

    The current samplers should be compatible with ``'binary'``,
    ``'multilabel-indicator'`` and ``'multiclass'`` targets only.

    Parameters
    ----------
    y : ndarray,
        The array containing the target.

    indicate_one_vs_all : bool, optional
        Either to indicate if the targets are encoded in a one-vs-all fashion.

    Returns
    -------
    y : ndarray,
        The returned target.

    is_one_vs_all : bool, optional
        Indicate if the target was originally encoded in a one-vs-all fashion.
        Only returned if ``indicate_multilabel=True``.

    """
    type_y = type_of_target(y)
    if type_y == "multilabel-indicator":
        if np.any(y.sum(axis=1) > 1):
            raise ValueError(
                "Imbalanced-learn currently supports binary, multiclass and "
                "binarized encoded multiclasss targets. Multilabel and "
                "multioutput targets are not supported."
            )
        y = y.argmax(axis=1)
    else:
        y = column_or_1d(y)

    return (y, type_y == "multilabel-indicator") if indicate_one_vs_all else y