(y_true, y_pred)
return y_type, y_true, y_pred
Check that y_true and y_pred belong to the same classification task

    This converts multiclass or binary types to a common shape, and raises a
    ValueError for a mix of multilabel and multiclass targets, a mix of
    multilabel formats, for the presence of continuous-valued or multioutput
    targets, or for targets of different lengths.

    Column vectors are squeezed to 1d, while multilabel formats are returned
    as CSR sparse label indicators.

    Parameters
    ----------
    y_true : array-like

    y_pred : array-like

    Returns
    -------
    type_true : one of {'multilabel-indicator', 'multiclass', 'binary'}
        The type of the true target data, as output by
        ``utils.multiclass.type_of_target``

    y_true : array or indicator matrix

    y_pred : array or indicator matrix
Check that y_true and y_pred belong to the same classification task
Check that y_true and y_pred belong to the same classification task
def _check_targets(y_true, y_pred):
    """Check that y_true and y_pred belong to the same classification task

    This converts multiclass or binary types to a common shape, and raises a
    ValueError for a mix of multilabel and multiclass targets, a mix of
    multilabel formats, for the presence of continuous-valued or multioutput
    targets, or for targets of different lengths.

    Column vectors are squeezed to 1d, while multilabel formats are returned
    as CSR sparse label indicators.

    Parameters
    ----------
    y_true : array-like

    y_pred : array-like

    Returns
    -------
    type_true : one of {'multilabel-indicator', 'multiclass', 'binary'}
        The type of the true target data, as output by
        ``utils.multiclass.type_of_target``

    y_true : array or indicator matrix

    y_pred : array or indicator matrix
    """
    check_consistent_length(y_true, y_pred)
    type_true = type_of_target(y_true)
    type_pred = type_of_target(y_pred)

    y_type = set([type_true, type_pred])
    if y_type == set(["binary", "multiclass"]):
        y_type = set(["multiclass"])

    if len(y_type) > 1:
        raise ValueError("Classification metrics can't handle a mix of {0} "
                         "and {1} targets".format(type_true, type_pred))

    # We can't have more than one value on y_type => The set is no more needed
    y_type = y_type.pop()

    # No metrics support "multiclass-multioutput" format
    if (y_type not in ["binary", "multiclass", "multilabel"]):
        raise ValueError("{0} is not supported".format(y_type))

    if y_type in ["binary", "multiclass"]:
        #Ravel column or 1d numpy array
        y_true = np.ravel(y_true)
        y_pred = np.ravel(y_pred)
        if y_type == "binary":
            unique_values = np.union1d(y_true, y_pred)
            if len(unique_values) > 2:
                y_type = "multiclass"

    if y_type.startswith('multilabel'):
        y_true = csr_matrix(y_true)
        y_pred = csr_matrix(y_pred)
        y_type = 'multilabel'

    return y_type, y_true, y_pred
def _check_targets ( y_true , y_pred ) : check_consistent_length ( y_true , y_pred ) type_true = type_of_target ( y_true ) type_pred = type_of_target ( y_pred ) y_type = set ( [ type_true , type_pred ] ) if y_type == set ( [ "binary" , "multiclass" ] ) : y_type = set ( [ "multiclass" ] ) if len ( y_type ) > 1 : raise ValueError ( "Classification metrics can't handle a mix of {0} " "and {1} targets" . format ( type_true , type_pred ) ) # We can't have more than one value on y_type => The set is no more needed y_type = y_type . pop ( ) # No metrics support "multiclass-multioutput" format if ( y_type not in [ "binary" , "multiclass" , "multilabel" ] ) : raise ValueError ( "{0} is not supported" . format ( y_type ) ) if y_type in [ "binary" , "multiclass" ] : #Ravel column or 1d numpy array y_true = np . ravel ( y_true ) y_pred = np . ravel ( y_pred ) if y_type == "binary" : unique_values = np . union1d ( y_true , y_pred ) if len ( unique_values ) > 2 : y_type = "multiclass" if y_type . startswith ( 'multilabel' ) : y_true = csr_matrix ( y_true ) y_pred = csr_matrix ( y_pred ) y_type = 'multilabel' return y_type , y_true , y_pred