apps/pretrained_compound/info_graph/utils.py
def calc_rocauc_score(labels, preds, valid):
    """compute ROC-AUC and averaged across tasks
    """
    if labels.ndim == 1:
        labels = labels.reshape(-1, 1)
        preds = preds.reshape(-1, 1)

    rocauc_list = []
    for i in range(labels.shape[1]):
        c_valid = valid[:, i].astype("bool")
        c_label, c_pred = labels[c_valid, i], preds[c_valid, i]
        #AUC is only defined when there is at least one positive data.
        if len(np.unique(c_label)) == 2:
            rocauc_list.append(roc_auc_score(c_label, c_pred))

    logging.info('Valid ratio: %s' % (np.mean(valid)))
    logging.info('Task evaluated: %s/%s' % (len(rocauc_list), labels.shape[1]))
    if len(rocauc_list) == 0:
        raise RuntimeError("No positively labeled data available. Cannot compute ROC-AUC.")

    return sum(rocauc_list)/len(rocauc_list)
compute ROC-AUC and averaged across tasks
    
compute ROC-AUC and averaged across tasks
compute ROC - AUC and averaged across tasks
def calc_rocauc_score(labels, preds, valid):
    if labels.ndim == 1:
        labels = labels.reshape(-1, 1)
        preds = preds.reshape(-1, 1)
    rocauc_list = []
    for i in range(labels.shape[1]):
        c_valid = valid[:, i].astype("bool")
        c_label, c_pred = labels[c_valid, i], preds[c_valid, i]
        if len(np.unique(c_label)) == 2:
            rocauc_list.append(roc_auc_score(c_label, c_pred))
    logging.info('Valid ratio: %s' % (np.mean(valid)))
    logging.info('Task evaluated: %s/%s' % (len(rocauc_list), labels.shape[1]))
    if len(rocauc_list) == 0:
        raise RuntimeError("No positively labeled data available. Cannot compute ROC-AUC.")
    return sum(rocauc_list)/len(rocauc_list)
def calc_rocauc_score ( labels , preds , valid ) : if labels . ndim == 1 : labels = labels . reshape ( - 1 , 1 ) preds = preds . reshape ( - 1 , 1 ) rocauc_list = [ ] for i in range ( labels . shape [ 1 ] ) : c_valid = valid [ : , i ] . astype ( "bool" ) c_label , c_pred = labels [ c_valid , i ] , preds [ c_valid , i ] if len ( np . unique ( c_label ) ) == 2 : rocauc_list . append ( roc_auc_score ( c_label , c_pred ) ) logging . info ( 'Valid ratio: %s' % ( np . mean ( valid ) ) ) logging . info ( 'Task evaluated: %s/%s' % ( len ( rocauc_list ) , labels . shape [ 1 ] ) ) if len ( rocauc_list ) == 0 : raise RuntimeError ( "No positively labeled data available. Cannot compute ROC-AUC." ) return sum ( rocauc_list ) / len ( rocauc_list )
compute ROC-AUC and averaged across tasks
compute ROC - AUC and averaged across tasks
"""compute ROC-AUC and averaged across tasks
    """ #AUC is only defined when there is at least one positive data.
labels
preds
valid