def get_scores(edges_pos, edges_neg, A_pred, adj_label):
    preds = A_pred[edges_pos.T]
    preds_neg = A_pred[edges_neg.T]
    logists = np.hstack([preds, preds_neg])
    labels = np.hstack([np.ones(preds.size(0)), np.zeros(preds_neg.size(0))])
    roc_auc = roc_auc_score(labels, logists)
    ap_score = average_precision_score(labels, logists)
    (precisions, recalls, thresholds) = precision_recall_curve(labels, logists)
    pr_auc = auc(recalls, precisions)
    warnings.simplefilter('ignore', RuntimeWarning)
    f1s = np.nan_to_num((((2 * precisions) * recalls) / (precisions + recalls)))
    best_comb = np.argmax(f1s)
    f1 = f1s[best_comb]
    pre = precisions[best_comb]
    rec = recalls[best_comb]
    thresh = thresholds[best_comb]
    adj_rec = copy.deepcopy(A_pred)
    adj_rec[(adj_rec < thresh)] = 0
    adj_rec[(adj_rec >= thresh)] = 1
    labels_all = adj_label.to_dense().view((- 1)).long()
    preds_all = adj_rec.view((- 1)).long()
    recon_acc = ((preds_all == labels_all).sum().float() / labels_all.size(0))
    results = {'roc': roc_auc, 'pr': pr_auc, 'ap': ap_score, 'pre': pre, 'rec': rec, 'f1': f1, 'acc': recon_acc, 'adj_recon': adj_rec}
    return results
def get_scores(edges_pos, edges_neg, A_pred, adj_label):
    preds = A_pred[edges_pos.T]
    preds_neg = A_pred[edges_neg.T]
    logists = np.hstack([preds, preds_neg])
    labels = np.hstack([np.ones(preds.size(0)), np.zeros(preds_neg.size(0))])
    roc_auc = roc_auc_score(labels, logists)
    ap_score = average_precision_score(labels, logists)
    (precisions, recalls, thresholds) = precision_recall_curve(labels, logists)
    pr_auc = auc(recalls, precisions)
    warnings.simplefilter('ignore', RuntimeWarning)
    f1s = np.nan_to_num((((2 * precisions) * recalls) / (precisions + recalls)))
    best_comb = np.argmax(f1s)
    f1 = f1s[best_comb]
    pre = precisions[best_comb]
    rec = recalls[best_comb]
    thresh = thresholds[best_comb]
    adj_rec = copy.deepcopy(A_pred)
    adj_rec[(adj_rec < thresh)] = 0
    adj_rec[(adj_rec >= thresh)] = 1
    labels_all = adj_label.to_dense().view((- 1)).long()
    preds_all = adj_rec.view((- 1)).long()
    recon_acc = ((preds_all == labels_all).sum().float() / labels_all.size(0))
    results = {'roc': roc_auc, 'pr': pr_auc, 'ap': ap_score, 'pre': pre, 'rec': rec, 'f1': f1, 'acc': recon_acc, 'adj_recon': adj_rec}
    return results