def kaplan_meier_AUC(rule):
    examples = rule.kb.bits_to_indices(rule.covered_examples)
    n_examples = float(len(examples))

    if n_examples == 0:
        return 0.0

    def n_alive(examples, day):

        def is_alive(ex):
            return rule.kb.get_score(ex) > day

        return len(filter(is_alive, examples))

    auc, day = 0, 0
    prev = -1
    while True:
        alive = n_alive(examples, day)
        day += 14

        curr = alive/n_examples
        if prev != -1:
            auc += 2.0/(prev + curr)
        prev = curr

        if alive == 0:
            break

    #print auc
    return auc


# Bounds of interest for each score function
# A rule is interesting if its score is in (A, B] as defined below.
dataset/ETHPy150Open anzev/hedwig/hedwig/stats/scorefunctions.py/kaplan_meier_AUC/swapped operands of `/`