Exemplo n.º 1
0
data = np.genfromtxt("raw CVR.csv", delimiter=",")
reps = 100

performance = []
train_size = 35
test_size = 400

total_elems = range(len(data))
train_elems = r.sample(total_elems, train_size)
test_elems = [x for x in total_elems if x not in train_elems]

single_err = 0

start = time.time()
for rep in range(reps):
    test_net = Net(len(data[0, 0:-2]), 1, 3, 3, 3)
    for n in xrange(1000):
        train_err = 0
        accuracy = 0
        for i in train_elems:
            single_err = test_net.err(data[i, 0:-2], data[i, -1])
            output = test_net.feedforward(data[i, 0:-2])[0]
            if abs(output - data[i, 0]) < 1:
                accuracy += 1
            print "SINGLE RUN ERR: %f" % (single_err)
            train_err += single_err
        train_err /= len(train_elems)
        accuracy = float(accuracy) / train_size
        print "MEAN RUN ERR: %f\n" % (train_err)
        print "MEAN RUN ACC: %f\n" % (accuracy)
        raw_input("Enter...")