Beispiel #1
0
 def fpr(tau):
     """fpr = false pos / total neg"""
     return ilen(x for x in negatives if prediction[x] > tau) / num_neg
Beispiel #2
0
 def fnr(tau):
     """fnr = false neg / total pos"""
     return ilen(
         x for x in positives if not (prediction[x] > tau)) / num_pos
Beispiel #3
0
 def count(self):
     return sum(self.ctx.runJob(self, lambda x: ilen(x)))
Beispiel #4
0
    n = a.length
    c = a.alphabet
    u_size = c**n
    err = a.error
    epochs = a.epochs

    xs = gen.make_uniform_words(num_exs, n, c)
    ys = {
        "uniform": lambda xs: gen.label_uniform(xs),
        "line": lambda xs: gen.label_line(xs, n, c),
        "polynomial": lambda xs: gen.label_polynomial(xs, n),
        "parity": lambda xs: gen.label_parity(xs),
        "circle": lambda xs: gen.label_circle(xs, n, c),
    }[a.generator](xs)

    num_pos = ilen(x for x, y in zip(xs, ys) if y)
    num_neg = ilen(x for x, y in zip(xs, ys) if not y)

    print("n={}, c={}, |U|={}, |K|={}, |T|={}".format(n, c, u_size, num_pos,
                                                      num_neg))

    if a.filter == "bloom":
        print("Running Bloom test...")
        bloom_test(xs, ys, num_pos, num_neg, n=n, c=c, e=err)
    elif a.filter == "toast":
        print("Running toast test...")
        toast_test(xs, ys, num_pos, num_neg, n=n, c=c, err=err, epochs=epochs)
    elif a.filter == "sandwich":
        print("Running sandwich test...")
        sandwich_test(xs,
                      ys,
def part2(passwords):
    """Solve for the answer to part 2."""
    def valid(password):
        return any(chain == 2 for chain in chain_lengths(password))

    return ilen(filter(valid, passwords))
Beispiel #6
0
 def n_differ_group(group):
     n = ilen(group)
     return n * (n_https_paths - n)
Beispiel #7
0
 def count(self):
     return sum(self.ctx.runJob(self, lambda x: ilen(x)))