def roc_auc_score(y_true, y_score, average='macro', sample_weight=None):
 def _binary_roc_auc_score(y_true, y_score, sample_weight=None):
  if (len(np.unique(y_true)) != 2):
   raise ValueError('Only one class present in y_true. ROC AUC score is not defined in that case.')
  (fpr, tpr, tresholds) = roc_curve(y_true, y_score, sample_weight=sample_weight)
  return auc(fpr, tpr, reorder=True)
 return _average_binary_score(_binary_roc_auc_score, y_true, y_score, average, sample_weight=sample_weight)

def roc_auc_score ( y_true , y_score , average = 'macro' , sample_weight = None ) : def _binary_roc_auc_score ( y_true , y_score , sample_weight = None ) : if ( len ( np . unique ( y_true ) ) != 2 ) : raise ValueError ( 'Only one class present in y_true. ROC AUC score is not defined in that case.' ) ( fpr , tpr , tresholds ) = roc_curve ( y_true , y_score , sample_weight = sample_weight ) return auc ( fpr , tpr , reorder = True ) return _average_binary_score ( _binary_roc_auc_score , y_true , y_score , average , sample_weight = sample_weight )
compute area under the curve from prediction scores note: this implementation is restricted to the binary classification task or multilabel classification task in label indicator format .