def chisq(rule):
    N = len(rule.kb.examples)
    z = rule.distribution[rule.target]/float(N)
    x = rule.coverage/float(N)
    y = rule.kb.distribution[rule.target]/float(N)
    if x not in [0, 1] and y not in [0, 1]:
        return N*(z - x*y)**2 / float(x*y*(1 - x)*(1 - y))
    else:
        return 0
dataset/ETHPy150Open anzev/hedwig/hedwig/stats/scorefunctions.py/chisq/original