(output, target)
return stats
Calculate statistics including mAP, AUC, etc.

    Args:
      output: 2d array, (samples_num, classes_num)
      target: 2d array, (samples_num, classes_num)

    Returns:
      stats: list of statistic of each class.
Calculate statistics including mAP, AUC, etc.
Calculate statistics including mAP AUC etc .
def calculate_stats(output, target):
    """Calculate statistics including mAP, AUC, etc.

    Args:
      output: 2d array, (samples_num, classes_num)
      target: 2d array, (samples_num, classes_num)

    Returns:
      stats: list of statistic of each class.
    """

    classes_num = target.shape[-1]
    stats = []

    # Class-wise statistics
    for k in range(classes_num):

        # Average precision
        avg_precision = metrics.average_precision_score(
            target[:, k], output[:, k], average=None)

        # AUC
        auc = metrics.roc_auc_score(target[:, k], output[:, k], average=None)

        # Precisions, recalls
        (precisions, recalls, thresholds) = metrics.precision_recall_curve(
            target[:, k], output[:, k])

        # FPR, TPR
        (fpr, tpr, thresholds) = metrics.roc_curve(target[:, k], output[:, k])

        save_every_steps = 1000     # Sample statistics to reduce size
        dict = {'precisions': precisions[0::save_every_steps],
                'recalls': recalls[0::save_every_steps],
                'AP': avg_precision,
                'fpr': fpr[0::save_every_steps],
                'fnr': 1. - tpr[0::save_every_steps],
                'auc': auc}
        stats.append(dict)

    return stats
def calculate_stats ( output , target ) : classes_num = target . shape [ - 1 ] stats = [ ] # Class-wise statistics for k in range ( classes_num ) : # Average precision avg_precision = metrics . average_precision_score ( target [ : , k ] , output [ : , k ] , average = None ) # AUC auc = metrics . roc_auc_score ( target [ : , k ] , output [ : , k ] , average = None ) # Precisions, recalls ( precisions , recalls , thresholds ) = metrics . precision_recall_curve ( target [ : , k ] , output [ : , k ] ) # FPR, TPR ( fpr , tpr , thresholds ) = metrics . roc_curve ( target [ : , k ] , output [ : , k ] ) save_every_steps = 1000 # Sample statistics to reduce size dict = { 'precisions' : precisions [ 0 : : save_every_steps ] , 'recalls' : recalls [ 0 : : save_every_steps ] , 'AP' : avg_precision , 'fpr' : fpr [ 0 : : save_every_steps ] , 'fnr' : 1. - tpr [ 0 : : save_every_steps ] , 'auc' : auc } stats . append ( dict ) return stats