def enrichment_score(rule):
    # The enrichment score of a rule covering all examples is 1
    if rule.coverage == rule.kb.n_examples():
        return 1.0
    if rule.coverage == 0:
        return - 1 / float(rule.kb.n_examples())
    increment = {}
    incr1 = 1 / float(rule.coverage)
    incr2 = 1 / float(rule.coverage - rule.kb.n_examples())
    max_diff = 0
    # All examples
    for ex in rule.kb.examples:
        increment[ex] = -incr2
    for ex in rule.examples():
        increment[ex] = incr1
    partial = 0
    for ex in rule.kb.examples:
        partial += increment[ex]
        if partial > max_diff:
            max_diff = partial
    return max_diff
dataset/ETHPy150Open anzev/hedwig/hedwig/stats/scorefunctions.py/enrichment_score/swapped operands of `-`