for (int i = 0; i < data.size(); ++i)
{
Sample pair = data.get(i);
network.feedforwardStep(pair.getInput());
DoubleList networkResult = network.getResult();
DoubleList realResult = pair.getOutput();
double error = JNMFMathUtils.distance(networkResult, realResult);
averageError += error;
if (data.isSplitedOnClasses())
{
int guessedClass = JNMFMathUtils.indexOfMaxElement(networkResult);
int realClass = JNMFMathUtils.indexOfMaxElement(realResult);
if (guessedClass != realClass)
{
totalNotGuessedClasses++;
notGuessedClasses[realClass]++;
}
}
}
averageError /= data.size();
res.averageError = averageError;
if (data.isSplitedOnClasses())
{
DoubleList notGuessedPersentByClasses = new ArrayDoubleList();
for (int i = 0; i < data.getOutputsCount(); ++i)
{
double error = (double) notGuessedClasses[i] / (double) data.calcCountOfItems(i);
if (Double.isNaN(error))
{
error = 0;
}
notGuessedPersentByClasses.add(error);
}
res.totalNotGuessedClassesPercent = (double) totalNotGuessedClasses / (double) data.size();
res.notGuessedClassesPercents = notGuessedPersentByClasses;
}