@Override
public Object read(final InputStream is) {
final EncogReadHelper in = new EncogReadHelper(is);
EncogFileSection section;
final BasicMLDataSet samples = new BasicMLDataSet();
Map<String, String> networkParams = null;
PNNKernelType kernel = null;
PNNOutputMode outmodel = null;
int inputCount = 0;
int outputCount = 0;
double error = 0;
double[] sigma = null;
while ((section = in.readNextSection()) != null) {
if (section.getSectionName().equals("PNN")
&& section.getSubSectionName().equals("PARAMS")) {
networkParams = section.parseParams();
}
if (section.getSectionName().equals("PNN")
&& section.getSubSectionName().equals("NETWORK")) {
final Map<String, String> params = section.parseParams();
inputCount = EncogFileSection.parseInt(params,
PersistConst.INPUT_COUNT);
outputCount = EncogFileSection.parseInt(params,
PersistConst.OUTPUT_COUNT);
kernel = PersistBasicPNN.stringToKernel(params
.get(PersistConst.KERNEL));
outmodel = PersistBasicPNN.stringToOutputMode(params
.get(PersistBasicPNN.PROPERTY_outputMode));
error = EncogFileSection
.parseDouble(params, PersistConst.ERROR);
sigma = section.parseDoubleArray(params,
PersistConst.SIGMA);
}
if (section.getSectionName().equals("PNN")
&& section.getSubSectionName().equals("SAMPLES")) {
for (final String line : section.getLines()) {
final List<String> cols = EncogFileSection
.splitColumns(line);
int index = 0;
final MLData inputData = new BasicMLData(inputCount);
for (int i = 0; i < inputCount; i++) {
inputData.setData(i,
CSVFormat.EG_FORMAT.parse(cols.get(index++)));
}
final MLData idealData = new BasicMLData(outputCount);
idealData.setData(0,CSVFormat.EG_FORMAT.parse(cols.get(index++)));
final MLDataPair pair = new BasicMLDataPair(inputData,idealData);
samples.add(pair);
}
}
}
final BasicPNN result = new BasicPNN(kernel, outmodel, inputCount,