final List<ColumnInfo> outputColumns = metadata.resolveColumns(VariableType.OUT);
// first pass - calc values ranges
for (int i = 0; i < forecast.size(); ++i)
{
DoubleList output = networkKorecast.get(i).getOutput();
for (ColumnInfo columnInfo : outputColumns)
{
Double currentMin = minValues.get(columnInfo);
Double currentMax = maxValues.get(columnInfo);
int firstIndex = metadata.getFirstIndexInTrainingDataset(columnInfo);
int endIndex = metadata.getEndIndexInTrainingDataset(columnInfo);
double value = 0;
if (columnInfo.getDataType() == DataType.Number)
{
value = output.get(firstIndex);
}
if (columnInfo.getDataType() == DataType.Boolean)
{
value = output.get(firstIndex);
}
if (columnInfo.getDataType() == DataType.Category)
{
value = calcSuperiority(output.subList(firstIndex, endIndex));
}
if (value < currentMin)
{
minValues.put(columnInfo, value);
}
if (value > currentMax)
{
maxValues.put(columnInfo, value);
}
}
}
// second pass - calc confidence
for (ColumnInfo columnInfo : outputColumns)
{
Double currentMin = minValues.get(columnInfo);
Double currentMax = maxValues.get(columnInfo);
int firstIndex = metadata.getFirstIndexInTrainingDataset(columnInfo);
int endIndex = metadata.getEndIndexInTrainingDataset(columnInfo);
DoubleList confidence = new ArrayDoubleList();
for (int i = 0; i < forecast.size(); ++i)
{
DoubleList output = networkKorecast.get(i).getOutput();
double value = 0;
if (columnInfo.getDataType() == DataType.Number)
{
value = output.get(firstIndex);
}
if (columnInfo.getDataType() == DataType.Boolean)
{
value = output.get(firstIndex);
}
if (columnInfo.getDataType() == DataType.Category)
{
value = calcSuperiority(output.subList(firstIndex, endIndex));
}
confidence.add(JNMFMathUtils.reflectToInterval(value, currentMin, currentMax, 0, 1));
}