# Buggy code
def type_of_target(y):
    """Determine the type of data indicated by the target.

    Note that this type is the most specific type that can be inferred.
    For example:

        * ``binary`` is more specific but compatible with ``multiclass``.
        * ``multiclass`` of integers is more specific but compatible with
          ``continuous``.
        * ``multilabel-indicator`` is more specific but compatible with
          ``multiclass-multioutput``.

    Parameters
    ----------
    y : array-like

    Returns
    -------
    target_type : string
        One of:

        * 'continuous': `y` is an array-like of floats that are not all
          integers, and is 1d or a column vector.
        * 'continuous-multioutput': `y` is a 2d tensor of floats that are
          not all integers, and both dimensions are of size > 1.
        * 'binary': `y` contains <= 2 discrete values and is 1d or a column
          vector.
        * 'multiclass': `y` contains more than two discrete values, is not a
          sequence of sequences, and is 1d or a column vector.
        * 'multiclass-multioutput': `y` is a 2d tensor that contains more
          than two discrete values, is not a sequence of sequences, and both
          dimensions are of size > 1.
        * 'multilabel-indicator': `y` is a label indicator matrix, a tensor
          of two dimensions with at least two columns, and at most 2 unique
          values.
        * 'unknown': `y` is array-like but none of the above, such as a 3d
          tensor, sequence of sequences, or a tensor of non-sequence objects.

    Examples
    --------
    >>> import mars.tensor as mt
    >>> from mars.learn.utils.multiclass import type_of_target
    >>> type_of_target([0.1, 0.6]).execute()
    'continuous'
    >>> type_of_target([1, -1, -1, 1]).execute()
    'binary'
    >>> type_of_target(['a', 'b', 'a']).execute()
    'binary'
    >>> type_of_target([1.0, 2.0]).execute()
    'binary'
    >>> type_of_target([1, 0, 2]).execute()
    'multiclass'
    >>> type_of_target([1.0, 0.0, 3.0]).execute()
    'multiclass'
    >>> type_of_target(['a', 'b', 'c']).execute()
    'multiclass'
    >>> type_of_target(mt.array([[1, 2], [3, 1]])).execute()
    'multiclass-multioutput'
    >>> type_of_target([[1, 2]]).execute()
    'multiclass-multioutput'
    >>> type_of_target(mt.array([[1.5, 2.0], [3.0, 1.6]])).execute()
    'continuous-multioutput'
    >>> type_of_target(mt.array([[0, 1], [1, 1]])).execute()
    'multilabel-indicator'
    """
    valid_types = (Sequence, spmatrix) if spmatrix is not None else (Sequence,)
    valid = (isinstance(y, valid_types) or hasattr(y, "__array__")) and not isinstance(
        y, str
    )

    if not valid:
        raise ValueError(f"Expected array-like (array or non-string sequence), got {y}")

    sparse_pandas = y.__class__.__name__ in ["SparseSeries", "SparseArray"]
    if sparse_pandas:  # pragma: no cover
        raise ValueError("y cannot be class 'SparseSeries' or 'SparseArray'")

    if isinstance(y, (Base, Entity)):
        y = mt.tensor(y)

    op = TypeOfTarget(y=y)
    return op(y)


# Traceback (ValueError)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-52-f2912f2e33a0> in <module>
1 from mars.learn.metrics import accuracy_score
----> 2 accuracy_score(y_test,y_pred).execute()

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_classification.py in accuracy_score(y_true, y_pred, normalize, sample_weight, session, run_kwargs)
178     op = AccuracyScore(y_true=y_true, y_pred=y_pred, normalize=normalize,
179                        sample_weight=sample_weight)
--> 180     score = op(y_true, y_pred)
181     return score.execute(session=session, **(run_kwargs or dict()))

/home/tops/lib/python3.6/site-packages/mars/utils.py in _inner(*args, **kwargs)
455         def _inner(*args, **kwargs):
456             with self:
--> 457                 return func(*args, **kwargs)
458
459         return _inner

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_classification.py in __call__(self, y_true, y_pred)
76
77     def __call__(self, y_true, y_pred):
---> 78         type_true, y_true, y_pred = _check_targets(y_true, y_pred)
79         self._type_true = type_true
80         inputs = [y_true, y_pred, type_true]

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_check_targets.py in _check_targets(y_true, y_pred)
193     """
194     op = CheckTargets(y_true=y_true, y_pred=y_pred)
--> 195     return op(y_true, y_pred)

/home/tops/lib/python3.6/site-packages/mars/utils.py in _inner(*args, **kwargs)
455         def _inner(*args, **kwargs):
456             with self:
--> 457                 return func(*args, **kwargs)
458
459         return _inner

/home/tops/lib/python3.6/site-packages/mars/learn/metrics/_check_targets.py in __call__(self, y_true, y_pred)
82         if isinstance(y_pred, (Base, Entity)):
83             inputs.append(y_pred)
---> 84         self._type_true = type_of_target(y_true)
85         self._type_pred = type_of_target(y_pred)
86         inputs.extend([self._type_true, self._type_pred])

/home/tops/lib/python3.6/site-packages/mars/learn/utils/multiclass.py in type_of_target(y)
403
404     if not valid:
--> 405         raise ValueError(f'Expected array-like (array or non-string sequence), got {y}')
406
407     sparse_pandas = (y.__class__.__name__ in ['SparseSeries', 'SparseArray'])

ValueError: Expected array-like (array or non-string sequence), got 159615    0
134010    0
199100    0
137756    0
200050    0
..
219880    0
82326     0
184439    0
198518    0
109959    0
Name: label_bigint, Length: 1146788, dtype: int64

# Fixed code
def type_of_target(y):
    """Determine the type of data indicated by the target.

    Note that this type is the most specific type that can be inferred.
    For example:

        * ``binary`` is more specific but compatible with ``multiclass``.
        * ``multiclass`` of integers is more specific but compatible with
          ``continuous``.
        * ``multilabel-indicator`` is more specific but compatible with
          ``multiclass-multioutput``.

    Parameters
    ----------
    y : array-like

    Returns
    -------
    target_type : string
        One of:

        * 'continuous': `y` is an array-like of floats that are not all
          integers, and is 1d or a column vector.
        * 'continuous-multioutput': `y` is a 2d tensor of floats that are
          not all integers, and both dimensions are of size > 1.
        * 'binary': `y` contains <= 2 discrete values and is 1d or a column
          vector.
        * 'multiclass': `y` contains more than two discrete values, is not a
          sequence of sequences, and is 1d or a column vector.
        * 'multiclass-multioutput': `y` is a 2d tensor that contains more
          than two discrete values, is not a sequence of sequences, and both
          dimensions are of size > 1.
        * 'multilabel-indicator': `y` is a label indicator matrix, a tensor
          of two dimensions with at least two columns, and at most 2 unique
          values.
        * 'unknown': `y` is array-like but none of the above, such as a 3d
          tensor, sequence of sequences, or a tensor of non-sequence objects.

    Examples
    --------
    >>> import mars.tensor as mt
    >>> from mars.learn.utils.multiclass import type_of_target
    >>> type_of_target([0.1, 0.6]).execute()
    'continuous'
    >>> type_of_target([1, -1, -1, 1]).execute()
    'binary'
    >>> type_of_target(['a', 'b', 'a']).execute()
    'binary'
    >>> type_of_target([1.0, 2.0]).execute()
    'binary'
    >>> type_of_target([1, 0, 2]).execute()
    'multiclass'
    >>> type_of_target([1.0, 0.0, 3.0]).execute()
    'multiclass'
    >>> type_of_target(['a', 'b', 'c']).execute()
    'multiclass'
    >>> type_of_target(mt.array([[1, 2], [3, 1]])).execute()
    'multiclass-multioutput'
    >>> type_of_target([[1, 2]]).execute()
    'multiclass-multioutput'
    >>> type_of_target(mt.array([[1.5, 2.0], [3.0, 1.6]])).execute()
    'continuous-multioutput'
    >>> type_of_target(mt.array([[0, 1], [1, 1]])).execute()
    'multilabel-indicator'
    """
    valid_types = (Sequence, spmatrix) if spmatrix is not None else (Sequence,)
    valid = (
        isinstance(y, valid_types)
        or hasattr(y, "__array__")
        or hasattr(y, "__mars_tensor__")
    ) and not isinstance(y, str)

    if not valid:
        raise ValueError(f"Expected array-like (array or non-string sequence), got {y}")

    sparse_pandas = y.__class__.__name__ in ["SparseSeries", "SparseArray"]
    if sparse_pandas:  # pragma: no cover
        raise ValueError("y cannot be class 'SparseSeries' or 'SparseArray'")

    if isinstance(y, (Base, Entity)):
        y = mt.tensor(y)

    op = TypeOfTarget(y=y)
    return op(y)