def stats(index_and_true_and_retrieved):
    """ Returns comma-separated list of accuracy stats

        Included are (relevant instances, retrieved instances, overlap,
                        precision, recall, f-score)
        
        index_and_true_and_retrieved is composed of:
        index: used to track which sample is associated with the stats
        true: set of true instances
        retrieved: set of retrieved indexes

        Return value: (index, tuple of stats)
    """
    index, true, recovered = index_and_true_and_retrieved
    relevant = len(true)
    retrieved = len(recovered)
    overlap = len(true.intersection(recovered))
    try:
        precision = float(overlap) / retrieved
    except ZeroDivisionError:
        precision = 1
    try:
        recall = float(overlap) / relevant
    except ZeroDivisionError:
        recall = 1
    try:
        fscore = 2 * precision * recall / (precision + recall)
    except ZeroDivisionError:
        fscore = 1
    return (index, (relevant, retrieved, overlap, precision, recall, fscore))