def errorOnDataSet(network, ds, measure):
    N = len(ds)
    error = 0.0
    correct = 0
    incorrect = 0
    for instance in ds:
        network.setInputValues(instance.getData())
        network.run()
        actual = instance.getLabel().getContinuous()
        predicted = network.getOutputValues().get(0)
        predicted = max(min(predicted, 1), 0)
        if (abs((predicted - actual)) < 0.5):
            correct += 1
        else:
            incorrect += 1
        output = instance.getLabel()
        output_values = network.getOutputValues()
        example = Instance(output_values, Instance(output_values.get(0)))
        error += measure.value(output, example)
    MSE = (error / float(N))
    acc = (correct / float((correct + incorrect)))
    return (MSE, acc)
def errorOnDataSet(network, ds, measure):
    N = len(ds)
    error = 0.0
    correct = 0
    incorrect = 0
    for instance in ds:
        network.setInputValues(instance.getData())
        network.run()
        actual = instance.getLabel().getContinuous()
        predicted = network.getOutputValues().get(0)
        predicted = max(min(predicted, 1), 0)
        if (abs((predicted - actual)) < 0.5):
            correct += 1
        else:
            incorrect += 1
        output = instance.getLabel()
        output_values = network.getOutputValues()
        example = Instance(output_values, Instance(output_values.get(0)))
        error += measure.value(output, example)
    MSE = (error / float(N))
    acc = (correct / float((correct + incorrect)))
    return (MSE, acc)