Without seeing your data I cannot really say where the discrepancy is coming from. I suspect some of the data elements have much higher errors than others. If you use this method, it will give you the detail for how the error is calculated and what the "current error" is at each element as it progresses through your data. This will generate quite a bit of output if your data set is large.
public static void errorDiagnostic(BasicNetwork network, MLDataSet dataSet) {
int count = 0;
double totalError = 0;
System.out.println("Network error: " + network.calculateError(dataSet));
for(MLDataPair pair : dataSet) {
MLData actual = network.compute(pair.getInput());
System.out.println("Evaluating element " + count + " : " + pair.getInput().toString());
for(int i=0;i<pair.getIdeal().size();i++) {
double delta = Math.abs(actual.getData(i) - pair.getIdeal().getData(i));
totalError += delta*delta;
count++;
double currentError = totalError/count;
System.out.println("\tIdeal: " + pair.getIdeal().getData(i) + ", Actual: " + actual.getData(i) + ", Delta: " + delta + ", Current Error: " + currentError);
}
}
}
For example, the output for a trained XOR (from the Encog hello world app) is:
Network error: 0.009643582111728128
Evaluating element 0 : [BasicMLData:0.0,0.0]
Ideal: 0.0, Actual: 0.10384251352940682, Delta: 0.10384251352940682, Current Error: 0.01078326761610504
Evaluating element 1 : [BasicMLData:1.0,0.0]
Ideal: 1.0, Actual: 0.9109458503325736, Delta: 0.08905414966742642, Current Error: 0.009356954594546711
Evaluating element 2 : [BasicMLData:0.0,1.0]
Ideal: 1.0, Actual: 0.8914073581830911, Delta: 0.10859264181690886, Current Error: 0.01016875701528963
Evaluating element 3 : [BasicMLData:1.0,1.0]
Ideal: 0.0, Actual: 0.08982236581744897, Delta: 0.08982236581744897, Current Error: 0.009643582111728128
This lets you see the degree to which each element is contributing to the error.