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("Can't handle mix of {0} and {1}".format(type_true, type_pred))
 y_type = y_type.pop()
 if (y_type not in ['binary', 'multiclass', 'multilabel-indicator']):
  raise ValueError('{0} is not supported'.format(y_type))
 if (y_type in ['binary', 'multiclass']):
  y_true = column_or_1d(y_true)
  y_pred = column_or_1d(y_pred)
 if y_type.startswith('multilabel'):
  y_true = csr_matrix(y_true)
  y_pred = csr_matrix(y_pred)
  y_type = 'multilabel-indicator'
 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 ( "Can't handle mix of {0} and {1}" . format ( type_true , type_pred ) ) y_type = y_type . pop ( ) if ( y_type not in [ 'binary' , 'multiclass' , 'multilabel-indicator' ] ) : raise ValueError ( '{0} is not supported' . format ( y_type ) ) if ( y_type in [ 'binary' , 'multiclass' ] ) : y_true = column_or_1d ( y_true ) y_pred = column_or_1d ( y_pred ) if y_type . startswith ( 'multilabel' ) : y_true = csr_matrix ( y_true ) y_pred = csr_matrix ( y_pred ) y_type = 'multilabel-indicator' 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 .